Enhancing Graph Colorization for Visualizations in MATLAB
조회 수: 9 (최근 30일)
이전 댓글 표시
I'm trying to reproduce graph visualizations similar to the ones shown in the attached figure (such as the vibrant surface and contour plots of optical solitons). However, the colors in my plots look dull or mismatched compared to the vivid, smooth, and rainbow-like color schemes I’ve seen in many research papers.
I've tried several color options in MATLAB, but they still don't look as appealing. Could someone please guide me on:
- How to apply professional-looking color schemes (like those in the figure)?
- How to smooth the color transitions for better visual quality?
- Any recommended colormaps, shading settings, or lighting options?
I would appreciate any suggestions or sample code to achieve more attractive and publication-quality results.


F = @(x,y)real(-0.7602345236e0*i * sqrt(0.2e1) * csch(0.5376349e-1 * t - x) * exp(0.231182795e1*i * (-0.537634e-1 * t + x)));
댓글 수: 1
답변 (2개)
Image Analyst
2025년 5월 10일
댓글 수: 2
DGM
2025년 5월 10일
편집: DGM
2025년 5월 11일
If you're asking how to construct something like what's given, it would probably be easier to generate the map programmatically than it would be to use the colormapeditor. William's answer covers that nicely, but as he said, it looks like what hsv() would return.
If you're still curious as to how to do it in colormapeditor(), you can open the hsv() map from its menu and see how it's constructed. The default map length is 256. Since the interpolating space is HSV, the breakpoints simply define a straight line over index = [1 maplength] and hue = [0 360*(1-1/maplength)], with saturation and value set to a constant 100%.
Since the hsv() map is intended to be cyclic, the map ends one hue step away from where it begins, but for a long maplength, this offset is visually negligible. For your (non-cyclic) use, the offset is unnecessary. William's example interpolates over hue = [0 360] instead, which is perfectly fine here.
William Rose
2025년 5월 10일
That looks like the hsv colormap.
F = @(x,t)real(-0.7602345236*1i*sqrt(2) * csch(0.05376349*t - x) * exp(2.31182795*1i*(-0.0537634*t + x)));
[x,t]=meshgrid(-9.95:.1:9.95,0.01:.1999:5);
[r,c]=size(x);
f=zeros(r,c);
for i=1:r
for j=1:c
f(i,j)=F(x(i,j),t(i,j));
end
end
surf(x,t,f,'EdgeColor','None')
xlabel('x'); ylabel('t'); zlabel('F(x,t)'); grid on
colormap('hsv')
댓글 수: 1
William Rose
2025년 5월 10일
편집: William Rose
2025년 5월 10일
The hsv colormap can be recreated by
hue1=(0:.005:1)';
mymap1=hsv2rgb([hue1,ones(201,2)]);
This works because columns 2 and 3 of X correspond to saturation and value, and we have set them to be all ones. Column 1 of X corresponds to hue. As hue varies from 0 to 1, the hue goes smoothly: red, yellow, green, cyan, blue, magenta, red. The help for colormap shows the hsv color bar and the other colorbars.
Copy the code from above to display the surface, this time with colormap "mymap":
F = @(x,t)real(-0.7602345236*1i*sqrt(2) * csch(0.05376349*t - x) * exp(2.31182795*1i*(-0.0537634*t + x)));
[x,t]=meshgrid(-9.95:.1:9.95,0.01:.1999:5);
[r,c]=size(x);
f=zeros(r,c);
for i=1:r
for j=1:c
f(i,j)=F(x(i,j),t(i,j));
end
end
surf(x,t,f,'EdgeColor','None')
xlabel('x'); ylabel('t'); zlabel('F(x,t)'); grid on
colormap(mymap1)
The plot above looks like the plot in my previous post, when we used colormap('hsv').
Now that you know how it works, you can adjust the hue variable to warp the colormap. You want hue to go monotonically from 0 to 1. You could do that with two or more intersecting line segments, or with curved functions, as shown below.
hue2=hue1.^0.5; hue3=hue1.^2;
hue4=[0:.00267:.198,linspace(.2,.8,51),.802:.00267:1]';
figure; plot(0:200,hue1,'-k.',0:200,hue2,'-k',0:200,hue3,'--k',0:200,hue4,':k')
legend('hue1=hsv map','hue2','hue3','hue4','Location','southeast')
grid on; xlabel('Index'); ylabel('Hue'),
Try plotting with the different maps:
mymap2=hsv2rgb([hue2,ones(201,2)]);
mymap3=hsv2rgb([hue3,ones(201,2)]);
mymap4=hsv2rgb([hue4,ones(201,2)]);
figure
ax(1)=subplot(221);
surf(x,t,f,'EdgeColor','None')
colormap(ax(1),mymap1); title('mymap 1=hsv map'); grid on
ax(2)=subplot(222);
surf(x,t,f,'EdgeColor','None')
colormap(ax(2),mymap2); title('mymap 2'); grid on
ax(3)=subplot(223);
surf(x,t,f,'EdgeColor','None')
colormap(ax(3),mymap3); title('mymap 3'); grid on
ax(4)=subplot(224);
surf(x,t,f,'EdgeColor','None')
colormap(ax(4),mymap4); title('mymap 4'); grid on
참고 항목
카테고리
Help Center 및 File Exchange에서 Color and Styling에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!