What is the correct handle for a scatter plot with 2 y-axes?

Hi, I think my question is very beginner, but I can't figure it out right now.
I want to make a scatter plot with 2 y-axes. Unfortunately, I have Matlab 2015b and cannot use yyaxis.
Instead, I found the following syntax to make a scatter plot
[ax, p1, p2]=plotyy(x1,y1,x2,y2);
set(p1,'Color','w'); % Color the lines white, so I only see the markers
set(p2,'Color','w');
The goal is to fit a regression line afterwards.
hold(ax(1),'on')
scatter(ax(1),x1,y1)
hold(ax(2),'on')
scatter(ax(2),x2,y2)
set(get(ax(1), 'Ylabel'), 'String', '\sigma_F_A');
set(get(ax(2), 'Ylabel'), 'String', '\sigma_M_D');
I managed to set the axis titles but I also want to set marker colors and shapes, as well as axis limits manually. But I don't know what to put instead of ax(1) and ax(2) to achieve the correct target.
When I "set(x1...)" or "set(get(y1,...))" the following error message pops up
Error using handle.handle/get Invalid or deleted object.
I hope you understand my question, thanks a lot in advance.

 Accepted Answer

The axes handles are stored in ax(1) and ax(2) and the plots are stored in p1 and p2. Use ax to set limits, labels, ticks and anything that is not related to the actual plot. To change properties of your plotted lines and markers, use the handles stored in p1 and p2. For example.
set(p1,'marker','o','color','r'...)
I believe the two x-axes are linked by default, so you can set xlabel, xticks, xlim etc by:
set(gca,'xlim',[xmin xmax],'xlabel',....)

Categories

Tags

Asked:

on 15 Aug 2018

Edited:

on 15 Aug 2018

Community Treasure Hunt

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

Start Hunting!