- Look up Tick Values and Labels AND Grid Lines in the documentation.
- Assign appropriate values to the appropriate properties.
How to access second axes in the PLOTYY syntax?
2 次查看(过去 30 天)
显示 更早的评论
Dear all,
This thread is a continuation from the following thread_1. Thanks to Walter for suggesting the code in the thread.
The idea was to add different XTickLabel at the second axes (i.e., ax(2)), specifically to change the label at the bottom X-axis into a set of number. I tried to access the second axis by plugging ax(2), but nothing is changing!.
Similarly, I want to add more instead of default one thicklabel at the second Y-axis. I assume, this too can be done by accessing the second axis.
Here is the code and some illustrative figure to show the intended objective.
Figure
ax = plotyy(st_X_hour, st_Vec_Y1_mean, st_X_hour, st_Y2, @(x,y) errorbar(x, y, st_Vec_Y1_Sd, '--x', 'MarkerSize', 15), @(x,y) plot(x, y, 'k') );
set(ax(1), 'Xtick', st_Xaxis_intrmit, 'XTickLabel',st_XLabel,'XAxisLocation','top');
xtickangle(ax(1), 90);
ylim(ax(1),[0.5 5.5])
nox=273:20:400;
set(ax(2), 'Xtick', nox, 'XTickLabel',1:numel(nox),'XAxisLocation','bottom');
Thanks in advance!
0 个评论
回答(1 个)
per isakson
2017-10-13
编辑:per isakson
2017-10-13
plotyy returns a vector of two axis-handles. (The diagram (before HG2 and I guess in HG2) was two plots on top of each other.)
>> ax = plotyy( (1:3), ones(1,3), (1:3),2*ones(1,3))
ax =
1x2 Axes array:
Axes Axes
>> ax(1)
ans =
Axes with properties:
XLim: [1 3]
YLim: [0 2]
XScale: 'linear'
YScale: 'linear'
GridLineStyle: '-'
Position: [0.1300 0.1100 0.7750 0.8150]
Units: 'normalized'
Show all properties
>> struct(ax(1))
Warning: ....
ans =
CameraPosition: [2 1 17.3205]
CameraPositionMode: 'auto'
CameraPosition_I: [2 1 17.3205]
CameraTarget: [2 1 0]
CameraTargetMode: 'auto'
CameraTarget_I: [2 1 0]
CameraUpVector: [0 1 0]
.............
And with a tool under development
>> dbnv( ax(1), 'YTick' )
YTick: [0 0.5000 1 1.5000 2]
YTick_I: [0 0.5000 1 1.5000 2]
YTickLabel: {5x1 cell}
YTickLabel_I: {5x1 cell}
YTickLabelMode: 'auto'
YTickLabelRotation: 0
YTickLabelRotation_I: 0
YTickLabelRotationMode: 'auto'
YTickLabels: {5x1 cell}
YTickLabels_I: {5x1 cell}
YTickLabelsMode: 'auto'
YTickMode: 'manual'
I'll first fix a problem, then I attach the function, dbnv
2 个评论
per isakson
2017-10-13
编辑:per isakson
2017-10-13
Here is the function, dbnv. It spits out a warning despite I have set the warning off.
The EraseMode property is no longer supported and will error in a future release.
id =
MATLAB:hg:EraseModeIgnored
>> dbnv( ax(1), 'YTick' )
85 opc = warning_off({
Warning: The DrawMode property will be removed in a future release. Use the SortMethod property instead.
> In dbnv>struct_array_ (line 134)
In dbnv (line 91)
Warning: The DrawMode property will be removed in a future release. Use the SortMethod property instead.
> In dbnv>struct_array_ (line 137)
In dbnv (line 91)
>> warning('query', 'MATLAB:hg:EraseModeIgnored' )
The state of warning 'MATLAB:hg:EraseModeIgnored' is 'off'.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Two y-axis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!