What is the easiest way to plot a circle annotation that maintains its shape regardless of figure dimensions?

20 Ansichten (letzte 30 Tage)
I am trying to annotate a bubblechart (R2022b) that is on a semilogy scale. I have a color scheme for the bubbles, and I am trying to create a custom legend showing what the color scheme means. I am having difficulty finding a convenient way to plot a circle and simply place it at a desired location relative to the figure. If I use "rectangle" or annotation("ellipse"), the shape changes if I change the figure dimensions, and I also have to back the numbers out of the axis units. Ideally I would be able to just specify the position using relative width and height values (relative to the figure, 0 to 1) and specify the size with a number of points (or, say, a fraction of the figure width). Am I missing something obvious?
EXAMPLE: Here's the result if I use the annotation command, where I've tweaked the ellipse size to match these particular figure dimensions: (the non-transparent green circle is added by this code)
annotation(gcf,'ellipse',[0.6 0.7 0.04 0.07],'FaceColor',[0 1 0],'LineStyle','none');
And here's what happens if I resize the figure:
I would like to have the green circle stay circular upon resizing the figure.
  4 Kommentare
Matthew McMahon
Matthew McMahon am 26 Okt. 2022
Bearbeitet: Matthew McMahon am 26 Okt. 2022
Relative to the figure. (Question edited to clarify this.) The size of the circles would preferably not be in terms of the data space of the axes.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Steve Eddins
Steve Eddins am 26 Okt. 2022
You can position a circle with the center specified in axes data space by plotting a single point using a circle marker. You can then set MarkerSize, MarkerEdgeColor, and MarkerFaceColor as desired. The size and shape of the circle marker will not change when you resize the figure.
plot(0.5,0.5,Marker = "o",MarkerSize = 20,...
MarkerEdgeColor = [0 1 0], MarkerFaceColor = [0 1 0])
This isn't exactly what you asked for because the circle's center is positioned in axes data space, instead of relative to the figure. I don't have a suggestion for that.

Kategorien

Mehr zu Data Distribution Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by