Reputation: 7
Im very new to matlab and I know its quite simple but I dont know what to search for..
I made a x,y scatter plot with efficiency(0~1)
scatter(sun(:,1),sun(:,2),19, sun(:,3),'fill')
My question is how to limit the color variation, for example from bright yellow to dark red instead of from dark blue to dark red, which are the default colors.
Another question I have is, is it possible to surround each data point with a black line to make it more clear to the viewer?
Thanks!
Upvotes: 0
Views: 938
Reputation: 8401
In reading "from bright yellow to dark red instead of from dark blue to dark red", I think the easiest solution is to use a limited (and flipped) version of the built-in colormap hot
instead of the (pre-R2014b) default jet
. You could limit jet
but may run into other colors unwittingly.
For example:
defaultHot = hot(100); % changing 100 changes the number of gradations
colormap(defaultHot(80:-1:1,:)); % flip so smaller values are bright yellow
Only taking the first 80 rows from the hot
colormap function gives a rich yellow for the small value color. Taking the entire colormap results in a hot white (which you may or may not like).
Further, an easy way to add a bounding black line is to use the ('MarkerEdgeColor','k')
scatter
name-value pair. Consider the sample input
x = rand(n,1);
y = rand(n,1);
z = exp(-20*((x-1/2).^2+(y-1/2).^2));
scatter(x,y,19,z,'filled','MarkerEdgeColor','k');
colorbar(); % Show colorbar
caxis([0,1]); % Explicitly stretch the colormap to cover the entire range
This produces the plot
Upvotes: 1