Questions about plotyy in Matlab

  • Context: MATLAB 
  • Thread starter Thread starter Old Guy
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary
SUMMARY

This discussion focuses on customizing the appearance of dual y-axes in MATLAB using the plotyy function. The user seeks to change the color of the tick labels on both vertical axes to black and to adjust the range of the second vertical axis independently. The solution involves using the set function to modify properties of the axes and the axis tight command for axis range adjustments. The Interactive Plotting Tool from MathWorks is also suggested as a resource for discovering additional parameters.

PREREQUISITES
  • Familiarity with MATLAB programming environment
  • Understanding of the plotyy function in MATLAB
  • Knowledge of MATLAB graphics properties and customization
  • Basic experience with axis manipulation in MATLAB
NEXT STEPS
  • Explore MATLAB's set function for modifying axis properties
  • Learn how to use the Interactive Plotting Tool in MATLAB
  • Research the axis tight command and its applications
  • Investigate dual-axis plotting techniques in MATLAB for advanced visualizations
USEFUL FOR

MATLAB users, data analysts, and engineers looking to enhance their data visualizations with dual y-axes and customize plot aesthetics effectively.

Old Guy
Messages
101
Reaction score
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
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:

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
8K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 4 ·
Replies
4
Views
7K