zwei x-Achsen < Matlab < Mathe-Software < Mathe < Vorhilfe
|
Status: |
(Frage) beantwortet | Datum: | 20:12 Mi 14.03.2007 | Autor: | MATLABer |
Aufgabe | Ich benötige für einen Plot in MATLAB zwei unterschiedlich skalierte x-Achsen in EINEM Plot - am Besten eine Skalierung unten und die andere Skalierung oben. Mit welchen Befehlen kann dies realisiert werden? |
Bitte um Hilfe
Ich habe diese Frage in keinem Forum auf anderen Internetseiten gestellt.
|
|
|
|
Status: |
(Antwort) fertig | Datum: | 12:02 Di 20.03.2007 | Autor: | MeeMa |
Hi,
hier aus der Matlab-Hilfe zu dem Thema 'Using Multiple X- and Y-Axes'
hoffe es hilft Dir weiter.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Using Multiple X- and Y-Axes
The XAxisLocation and YAxisLocation properties specify on which side of the graph to place the x- and y-axes. You can create graphs with two different x-axes and y-axes by superimposing two axes objects and using XAxisLocation and YAxisLocation to position each axis on a different side of the graph. This technique is useful to plot different sets of data with different scaling in the same graph.
Example -- Double Axis Graphs
This example creates a graph to display two separate sets of data using the bottom and left sides as the x- and y-axis for one, and the top and right sides as the x- and y-axis for the other.
Suppose you have two sets of data having different x- and y-ranges:
x1 = [0:.1:40];
y1 = 4.*cos(x1)./(x1+2);
x2 = [1:.2:20];
y2 = x2.^2./x2.^3;
Using low-level line and axes routines allows you to superimpose objects easily. Plot the first data, making the color of the line and the corresponding x- and y-axis the same to more easily associate them.
hl1 = line(x1,y1,'Color','r');
ax1 = gca;
set(ax1,'XColor','r','YColor','r')
Next, create another axes at the same location as the first, placing the x-axis on top and the y-axis on the right. Set the axes Color to none to allow the first axes to be visible and color code the x- and y-axis to match the data.
ax2 = axes('Position',get(ax1,'Position'),...
'XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none',...
'XColor','k','YColor','k');
Draw the second set of data in the same color as the x- and y-axis.
hl2 = line(x2,y2,'Color','k','Parent',ax2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|