How to Change the Color and Font Size of the Seond Axis of Plotyy?

前端 未结 2 405
既然无缘
既然无缘 2021-01-16 21:19

I have plotted two curves using plotyy function of MATLAB:

[AX,H1,H2] = plotyy(voltage_span, amplitude,voltage_span, Ca_SR);

The problem is

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-16 21:47

    To change the font size of the right axis, enter the following code:

    set(AX(2),'YColor', [1 0 0]); % Change the right Axis's color to red
    set(AX(2),'FontSize', 20); % Change the right Axis's font size to 20
    

    "YColor" property is the color of the right axis. Ax(2) holds the handle to the right axis(and Ax(1) to the left axis).

    You might ask why the following does not work:

    set(get(AX(2),'YColor'),[1 0 1]);
    

    The reason is that "YColor" is not a handle and

    get(AX(2),'YColor') 
    

    simply returns the color of the right axis (which is light green by default):

    >> get(AX(2), 'YColor')
    
    ans =
    
             0    0.5000         0
    

    However, for changing the left axis' label, you should write this:

    set(get(AX(2),'Ylabel'),'String','Fast Decay')
    

    Because 'Ylabel' property actually contains a handle to the label object.

    By the way, to remove the XTicks of the right axis, do this:

    set(AX(2),'XTick', []);
    

提交回复
热议问题