【问题标题】:How do I remove values from one y-axis when having multiple axes?当有多个轴时,如何从一个 y 轴中删除值?
【发布时间】:2020-09-19 13:05:17
【问题描述】:

如何从这个多轴图中删除右侧 y 轴的值? Code source.

figure
x1 = Pmax;
y1 = FuelCons;
line(x1,y1,'Color','r')
ax1 = gca; % current axes

ax1_pos = ax1.Position; % position of first axes
ax2 = axes('Position',ax1_pos,...
    'XAxisLocation','top',...
    'YAxisLocation','right',...
    'Color','none');

x2 = Cdrag;
y2 = FuelCons;
line(x2,y2,'Parent',ax2,'Color','k')

【问题讨论】:

    标签: matlab matlab-figure axes multiple-axes


    【解决方案1】:

    将轴的YColour 属性设置为none 可能是一个需要考虑的实现。最好考虑到 gca 是之前在代码中调用的最新轴。

    figure
    
    x1 = 0:0.1:40;
    y1 = 4.*cos(x1)./(x1+2);
    line(x1,y1,'Color','r')
    ax1 = gca; % current axes
    ax1.XColor = 'r';
    ax1.YColor = 'r';
    
    ax1_pos = ax1.Position; % position of first axes
    ax2 = axes('Position',ax1_pos,...
        'XAxisLocation','top',...
        'YAxisLocation','right',...
        'Color','none');
    
    set(gca,'YColor','none')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多