how to have the same settings on right Y axis from the left Y axis
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
endystrike
am 10 Jun. 2020
Kommentiert: Ameer Hamza
am 12 Jun. 2020
Hello everyone,
I struggling in having Y axis both on left and right side of a graph, but with the same settings, the same color and the same Y ticks...
I tried moving the following command "yyaxis right;" before assigning "ytickformat" and so on, but it creates a new axis from scratch and I don't know how to get the settings from the left Y axis and set them into the Y right axis.
Is there the possibility to get all the settings from Y left axis, save them into a variable and then set the Y right axis from the variable that stores everything?
Thanks
0 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 11 Jun. 2020
Following solution is adopted from this answer: https://www.mathworks.com/matlabcentral/answers/312653-matlab-object-assignment-copy-an-object-instead-of-creating-a-pointer#answer_243641
ax = axes();
yyaxis right
copyAxis(ax.YAxis(1), ax.YAxis(2))
function copyAxis(a, b)
p = properties(a).';
for i=1:numel(p) %copy all public properties
try %may fail if property is read-only
b.(p{i}) = a.(p{i});
catch
warning('failed to copy property: %s', p{i});
end
end
end
You can save the copyAxis function in a seperate file.
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Graphics Performance finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!