I have 2D line with varying color using surface. How do I modify colorbar for this plot without axes issues?
1 view (last 30 days)
Show older comments
I used Matt's answer from question How do I vary color along a 2D line? to create a line with color that varies along the line by plotting a surface. When I add a colorbar to this plot I get numbers all over the graph. The numbers correspond the axis labels. I got around this issue by giving location for colorbar. What I really want to do is have same colorbar scale for multiple plots. The same issue arises when I change the scale of the colorbar. Here is an example of my problem using Matt's code:
x = 0:.05:2*pi;
y = sin(x);
z = zeros(size(x));
col = x; % This is the color, vary with x in this case.
surface([x;x],[y;y],[z;z],[col;col],...
'facecol','no',...
'edgecol','interp',...
'linew',2);
h=colorbar('location','east');
caxis([-0.8,0.8]);
This issue occurs if I do not specify a location for colorbar or when I modify the scale using caxis. How do I to solve this issue and keep labels on my axes?
0 Comments
Answers (0)
See Also
Categories
Find more on Colormaps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!