Challenge - Change my avatar colors

The spy function without arguments does my avatar picture, white background and blue "spy".
  1. Change the background color
  2. Change the color of the "spy"
Tell me the code to perform the two tasks?
Please don't post the code if you appear on the first page of the Contributors or you are well known in the community for your MATLAB skills.
The prize is 4 reputation points, first answer that satisfy the requirements wins, next ones win 1 reputation point if they do the same but in some other way.
PS: The code is very simple, just two small lines.
The Challenge is complete, congratulations to the winner Nathan Greco and to Ian Wood for trying.
My code is this:
spy %draw the spy
set(gca,'Color',[1 0 0]) %change the background color
set(get(gca,'children'),'color',[1 1 0]) %change the "spy" color

4 件のコメント

Oleg Komarov
Oleg Komarov 2011 年 7 月 1 日
I am gonna create a fake account...mUahHAUhuAhua
Paulo Silva
Paulo Silva 2011 年 7 月 1 日
That's too much effort just for 4 rep points
Oleg Komarov
Oleg Komarov 2011 年 7 月 1 日
But think about all the broken hopes....MuhsuhAHuahua
Paulo Silva
Paulo Silva 2011 年 7 月 1 日
I edited the question several times in order to avoid cheating and also thought about the fake accounts but it would be too much effort for nothing.

サインインしてコメントする。

 採用された回答

Nathan Greco
Nathan Greco 2011 年 7 月 1 日

0 投票

My "spy" command gives me a picture of a dog:
spy
To change the background and outline color in one shot:
whitebg
To change just the background:
set(gca,'color','black');
To change just the outline:
set(get(gca,'children'),'markeredgecolor','yellow');

5 件のコメント

Paulo Silva
Paulo Silva 2011 年 7 月 1 日
That does it, just my second task is a little bit different, Ian replied first but his code isn't 100% what was requested.
Fangjun Jiang
Fangjun Jiang 2011 年 7 月 1 日
I think Nathan's code completes both tasks.
Nathan Greco
Nathan Greco 2011 年 7 月 1 日
What do you mean by the second task is different? The "spy" itself is changed via the 'markeredgecolor' property, no?
Paulo Silva
Paulo Silva 2011 年 7 月 1 日
I changed the color propertie of the axes children instead of the marker like you did, congratulations for wining this small contest :)
Matt Fig
Matt Fig 2011 年 7 月 1 日
Nathan, thanks for teaching this "old MATLAB dog" a new trick! I hadn't heard of WHITEBG before today.

サインインしてコメントする。

その他の回答 (1 件)

Ian Wood
Ian Wood 2011 年 7 月 1 日

1 投票

load spy
colormap(hot)

10 件のコメント

Paulo Silva
Paulo Silva 2011 年 7 月 1 日
Thanks for trying but just use spy instead of load spy and do the proper changes so the spy appears with different colors.
Ian Wood
Ian Wood 2011 年 7 月 1 日
Doesn't using a colormap change all of the colors in one succession?
Paulo Silva
Paulo Silva 2011 年 7 月 1 日
colormap changes the default colormap, I think it just applies to what you create after it's changed, maybe doing the spy function after it will work
Paulo Silva
Paulo Silva 2011 年 7 月 1 日
sorry but it doesn't work anyway, thanks for trying
Paulo Silva
Paulo Silva 2011 年 7 月 1 日
You got a vote for your efforts
Ian Wood
Ian Wood 2011 年 7 月 1 日
is it possible to do with the colormap function?
Paulo Silva
Paulo Silva 2011 年 7 月 1 日
I tried several ways without success but I'm no expert on those subjects, this code set(gcf,'Colormap',hot); changes the colormap but the colors remain the same
Nathan Greco
Nathan Greco 2011 年 7 月 1 日
I think that would work of spy consisted of a matrix of (image) data, rather than just some plotted points.
Paulo Silva
Paulo Silva 2011 年 7 月 1 日
spy
c=get(gca,'children');
x=get(c,'xdata');
y=get(c,'ydata');
cla
plot(x,y,'*')
set(gca,'ydir','reverse')
saveas(gcf,'spy.jpg')
im=imread('spy.jpg');
image(im)
colormap(gca,hot)
Ian was right in the part where the colormap would change the colors of the current figure, sorry about my mistake Ian but I can't make it to work anyway I try :(
Ian Wood
Ian Wood 2011 年 7 月 2 日
That's ok, I was just wondering if I was on the right track. Thanks for the code :)

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeDiscrete Data Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by