I would like to automatically create graphs of Hardness H and Young’s modulus E of samples as function of load L of indenter.
My goal is to get opaque markers connected with dashed lines. When using set(handle,'linestyle',spec) or line(...,'linestyle',spec) command I got markers or lines, never both of them – MATLAB throws error.
Is there way to get lines and markers without plotting two lines with same data and different specs? I’d like to continue with this to work with legend as described in another question (MATLAB: legend for plotyy with multiple data sets).
Here is my actual MWE code:
%data1 - m x 3 matrix with data for first sample:
[m,n]=size(data1);
%plots 1st sample data:
[ax,h1,h2]=plotyy([data1(1:m,1)],[data1(1:m,2)],[data1(1:m,1)],[data1(1:m,3)]);
set(h1,'linestyle','o')
set(h2,'linestyle','o')
%store colors:
c1=get(h1,'color');c2=get(h2,'color');
%plots 2nd sample hardness:
line('parent',ax(1),'xdata',[data2(1:m,1)],'ydata',[data2(1:m,2)],...
'color',c1,'linestyle','s');
%plots 2nd sample young's modulus
line('parent',ax(2),'xdata',[data2(1:m,1)],'ydata',[data2(1:m,3)],...
'color',c2,'linestyle','s');
I think you may be overcomplicating it?
Try something like this:
It produces the following image of opaque markers connected with dashed lines:
To support
plotyy, the process is basically the same, except you have to set some properties on both the parent and child axes. Here’s some example code:Which produces the following image: