How do I plot filled markers on top of two axis
7 views (last 30 days)
Show older comments
I got this minimal example:
X = linspace(1,10,20);
% Create left axis
ax1=gca;
p1 = plot(X, sin(X),'MarkerFaceColor','w','Marker','s','MarkerSize',10);
% Create right axis
ax2=axes('Position',get(ax1,'Position'),'YAxisLocation','right','Color','none');hold on
p2 = plot(X,cos(X), 'Color', 'r','MarkerFaceColor','w','Marker','o','MarkerSize',10);
and get this figure:
The rectangular marker on the right side is a white filled marker and should cover the axis line like the circular one. How can I do that?
Thx,
best regards
Stefan
0 Comments
Answers (2)
Alan Stevens
on 5 Aug 2020
Try changing the order:
X = linspace(1,10,20);
% Create axes
ax1=gca;
ax2=axes('Position',get(ax1,'Position'),'YAxisLocation','right','Color','none');hold on
p1 = plot(X, sin(X),'MarkerFaceColor','w','Marker','s','MarkerSize',10);
p2 = plot(X,cos(X), 'Color', 'r','MarkerFaceColor','w','Marker','o','MarkerSize',10);
0 Comments
steefan85
on 5 Aug 2020
10 Comments
Alan Stevens
on 5 Aug 2020
Edited: Alan Stevens
on 5 Aug 2020
Hmm. I guess the only other option is to export the data and plot it in another tool that does all you want. Apart from that, I'm out of ideas! This is a long way from your original question!
See Also
Categories
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!