Have legend reflect multiple marker sizes
Mostrar comentarios más antiguos
Hi, I have 5 sets of data each symbolized by a different size marker on my plot. I want the legend to reflect these different sizes. However, when I create the legend, the legend does not reflect the different marker sizes if the marker sizes are above 12pts. I have tried using both scatter() and plot() and in either case, the marker size in the legend does not change. My goal is to have 5 different marker sizes reflected in the legend. I'm using matlab R2023a. Any help is appreciated! I've included an example code below as well as a screenshot of the type of output I am looking for.
x = rand(100)*100;
y = rand(100)*100;
figure
scatter(x(1:20),y(1:20),12,'o','filled','MarkerFaceColor','b','MarkerEdgeColor','b')
hold on
scatter(x(20:40),y(20:40),24,'o','filled','MarkerFaceColor','b','MarkerEdgeColor','b')
hold on
scatter(x(40:60),y(40:60),48,'o','filled','MarkerFaceColor','b','MarkerEdgeColor','b')
hold on
scatter(x(60:80),y(60:80),96,'o','filled','MarkerFaceColor','b','MarkerEdgeColor','b')
hold on
scatter(x(80:100),y(80:100),192,'o','filled','MarkerFaceColor','b','MarkerEdgeColor','b')
legend('data1','data2','data3','data4','data5')
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Legend en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

