Questions about plotyy in Matlab

  • MATLAB
  • Thread starter Old Guy
  • Start date
  • Tags
    Matlab
In summary, the code shown contains a figure with two vertical axes and two plots, each with different colors. The user has two questions: how to change the color of the numbers along the axes, and how to adjust the range on one or both of the vertical axes. They suggest using the Interactive Plotting Tool to find the necessary parameter.
  • #1
Old Guy
103
1
Here is the relevant piece of code as it stands now:

figure(2)
[AX,H1,H2] = plotyy(plot2data(:,1),plot2data(:,2),plot2data(:,1),...
plot2data(:,3));
set(get(AX(1),'Ylabel'),'String','Mean Value of C_{a}','Color','k')
set(get(AX(2),'Ylabel'),'String','Mean Value of C_{b}','Color','k')
set(H1,'LineWidth',2,'Color','k')
set(H2,'LineWidth',2,'Color','r')
xlabel('K');
legend('Mean Value of C_{a}','Mean Value of C_{b}','Location','West');
title(strcat('T=',num2str(T)));

I have two questions. The first is that I want both vertical axes to be black - I'm currently getting different colors. The first two set commands above change the color of the axis label, but the numbers along the axes remain different colors. How can I change those?

The second question is: How can I change the range on one or both of the vertical axes? My immediate desire would be to do something like

axis tight

but only on AX(2).

Thanks!
 
Physics news on Phys.org
  • #2
I can't give you an exact answer, but you may be able to find the parameter you need with the Interactive Plotting Tool:
http://www.mathworks.com/help/techdoc/creating_plots/f9-47085.html

Good luck!
 
Last edited by a moderator:

Related to Questions about plotyy in Matlab

1. What is plotyy in Matlab and how does it differ from regular plot functions?

Plotyy in Matlab is a function that allows for the creation of two y-axes on a single plot. This means that two different sets of data can be plotted on the same graph with separate y-axes, making it easier to compare and analyze the relationship between the two data sets. This differs from regular plot functions in Matlab, which only allow for a single y-axis.

2. How do I use plotyy in Matlab?

To use plotyy in Matlab, you will need to provide two sets of data to be plotted, as well as the x-axis values. Then, simply call the plotyy function and pass in the two data sets and the x-axis values as parameters. You can also customize the appearance of the plot by adding additional parameters, such as color and line style.

3. Can I add a third y-axis using plotyy in Matlab?

No, plotyy in Matlab only allows for two y-axes to be displayed on a single plot. If you need to add a third y-axis, you can use the plot function to create a separate plot and then use the "hold on" command to overlay it on top of the plotyy plot.

4. How can I change the scale of the y-axes in plotyy?

To change the scale of the y-axes in plotyy, you can use the "ylim" function. This allows you to specify the minimum and maximum values for each y-axis. You can also use the "yticks" function to specify the tick marks on the y-axes.

5. Is there a way to add a title and labels to the y-axes in plotyy?

Yes, you can add a title and labels to the y-axes in plotyy by using the "ylabel" and "yyaxis" functions. The "ylabel" function allows you to add a label to a specific y-axis, while the "yyaxis" function allows you to specify which y-axis the following plot or label commands will apply to. You can also use the "title" function to add a title to the entire plot.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
509
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
964
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
743
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Back
Top