How to make a circle MarkerSize on a plot equal to a specific diameter relative to the scale being used

12 visualizaciones (últimos 30 días)
I have a question about using MarkerSize for 'Marker' = 'o' using the plot function
MarkerSize is given in points. I would like to set the diameter of the Marker 'o'
Is there a conversion to obtain a numerical value given by the scale you're using.
For example, on a degrees plot: plot(A, B, 'Marker', 'o', 'MarkerSize', .75)
where A and B are in degrees.
I would like the diameter to equal .75 degrees. Thanks for your help !

Respuesta aceptada

Walter Roberson
Walter Roberson el 31 de Ag. de 2011
It could be done in theory, through a multistep process involving finding the plotting area of the axes in units in points, and relating that to the xlim or ylim to determine the proper ratio.
Finding the actual plotting area inside the box limits is tricky in my experience; I'm not sure I have ever managed to do it.
This is a case where scatter() does not help; I generally turn to scatter() when point plotting via plot() is not sufficiently flexible, but scatter() uses points for its marker size as well.
Hmmm... you could probably rectangle() circles in places at the appropriate locations (the rectangle() routine can draw circles.)

Más respuestas (1)

Nando Trindade
Nando Trindade el 1 de Sept. de 2011
Looks like this command works well:
{rectangle('Position', [.250 .250 1.5 1.5],'Curvature', [1 1],'EdgeColor', 'r', 'FaceColor', 'r')}
'Position',[x y w h]
You have to adjust x and y by the radius you want your circle to be (in this case a 1.5 diameter) so that it lines up with your desired center point. The only downside seems to be that it won't accept vectors [:,1] for x y w and h. I'd have to loop through all my points to plot all the circles.
Thanks for the tip! Wasn't aware of the rectangle function.
  1 comentario
Walter Roberson
Walter Roberson el 1 de Sept. de 2011
arrayfun() the loop for simplicity. Something like,
w = 1.5;
arrayfun(@(x,y) rectangle('Position', [x-w/2, y-w/2, w, w], 'Curvature', [1 1], 'EdgeColor', 'r', 'FaceColor', 'r'), X, Y);
Different sizes for each would be a small modification:
arrayfun(@(x,y,w) rectangle('Position', [x-w/2, y-w/2, w, w], 'Curvature', [1 1], 'EdgeColor', 'r', 'FaceColor', 'r'), X, Y, W);

Iniciar sesión para comentar.

Categorías

Más información sobre Scatter Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by