MATLAB Answers

C G
0

Change marker color and size to non default color

Asked by C G
on 20 Jul 2018
Latest activity Commented on by Cg Gc on 8 Jul 2019
I am trying to plot a point on a map. I can make the map, plot my point, and change my style of my marker just fine. But I can't change the size or the color. I would like to make it a bit larger and purple, specifically, [.6 .2 1]. Can anyone help? Please see the attachment for what I have tried so far.
Here is the original code, which works, making my point blue.
load coastlines
figure('Color','w')%Colors the figure white.
axesm('stereo','Origin',[-90 0],'MapLatLimit',[-90 -30])
axis off;
framem on;
gridm on;
mlabel on;
plabel on;
setm(gca,'MLabelParallel',50)
geoshow(coastlat,coastlon,'DisplayType','polygon', 'FaceColor', 'white')
plot3m(-71.166,111.366,2690,'b.')
Thanks a bunch.

  0 Comments

Sign in to comment.

2 Answers

 Accepted Answer

When you plot, the color code 'b-o' is a shortcut to indicate colour (b), linestyle (-) and marker (o), in your case you are using blue dots:
plot3m(-71.166,111.366,2690,'b.')
so you can change that shortcut to whatever you want
plot3(-71.166,111.366,2690,'color', [.6 .2 1],'linestyle','none','marker','.','markersize',10 )
I tried this with plot3, but probably works the same with plot3m.

  3 Comments

This works well on every map except the contour map. A small purple dot is made, but it is on a blank screen. The maps is gone. Here is the code for the contour map.
[lat,lon,sfz] = bedmap2_data('sfz','res','5 km');
contourps(lat,lon,sfz) %Simple contours
close % clears Example 1
%In polar stereographic, with units
[C,h] = contourps(lat,lon,sfz,'km');
xlabel 'eastings (km)'
ylabel 'northings (km)'
cmocean 'haline'
clabel(C,h,'LabelSpacing',300,'fontsize',8)
close % clears Example 2
%Adds a color bar and specific elevations
contourps(lat,lon,sfz,0:200:5000,'km')
cb = colorbar;
ylabel(cb,'surface elevation (m)')
%Fills in the contours. Adds a color bar and some labels
contourfps(lat,lon,sfz,0:200:5000,'km')
cb = colorbar;
ylabel(cb,'surface elevation (m)')
%plot3ps(-71.166,111.366,2690,'color', [.6 .2 1],'linestyle','none','marker','.','markersize',10 )
plot(500000.000,2122603.232,'k.')%The plot3ps line does not work.
Add a call to hold on before you plot.
Works great. Thank you.
contourps(lat,lon,sfz,0:200:5000,'km')
cb = colorbar;
ylabel(cb,'surface elevation (m)')
%Fills in the contours. Adds a color bar and some labels
contourfps(lat,lon,sfz,0:200:5000, 'km')
hold on;
cb = colorbar;
ylabel(cb,'surface elevation (m)');
hold on;
plot (2361.1,-994.1,'color', [.0 .0 1],'linestyle','none','marker','.','markersize',15) %Law Dome
hold on;

Sign in to comment.


Answer by vishal rawat on 7 Jul 2019

How to change size of the marker with different value.

  1 Comment

In this line,
plot (2361.1,-994.1,'color', [.0 .0 1],'linestyle','none','marker','.','markersize',15)
the size of the marker is indicated by 'markersize', 15. If you want it to be a bigger marker, than change the 15 to any larger number. If you want it to be smaller, than change it to any number smaller than 15.

Sign in to comment.