Need help flipping axis values

13 Ansichten (letzte 30 Tage)
Chase Valo
Chase Valo am 17 Dez. 2019
Bearbeitet: Adam Danz am 18 Dez. 2019
I am plotting a series of data from excel, however the values on the x & y axis are flipped.
This is what I currently have:
stuff.PNG
This is what I am trying to accomplish:
yee.PNG

Antworten (2)

Adam Danz
Adam Danz am 17 Dez. 2019
Bearbeitet: Adam Danz am 17 Dez. 2019
Instead of plotting
plot(x,y)
plot
plot(y,x)
If you're using a different plotting function, the main idea is to just switch the x and y inputs.
If your input is a matrix, transpose it (which appears to be the case, judging from the axis ticks)
plot(x.')
  2 Kommentare
Chase Valo
Chase Valo am 17 Dez. 2019
Flipping x and y does give this:
u.PNG
However, the numbers for the x and y axis are still reversed and transposing has no effect
Adam Danz
Adam Danz am 17 Dez. 2019
Bearbeitet: Adam Danz am 18 Dez. 2019
How did you get the the figure you shared in "what I want to accomplish"? Did you plot that in Matlab? Where did you get those data from?
One possibility is that you're dealing with different units between the two figures. For example, the x axis in your plot indicate units of meters while the y axis are m^-2. When I look at other irradiance plots, often times units are in nanometers in which case your values look OK. Here are examples where the range of values along the x and y axes are similar to yours.
My guess is that your data and plot are fine but something is off with the other plot you're trying to copy - probably the units or maybe the axis ticks labels are incorrect.

Melden Sie sich an, um zu kommentieren.


Star Strider
Star Strider am 17 Dez. 2019
I am not certain what the problem may be.
Using your previous code:
%Constants:
h = 6.626e-34;
k = 1.381e-23;
c = 2.998e8;
t = 5800;
r_sun = 1.39e9/2;
r_earth = 1.5e11;
f_w = (r_sun/r_earth)^2;
%Function:
L_sun =@(l) f_w*((2*pi*h*c^2)./l.^5).*(1./(exp(h*c./(l*k*t))-1));
lambda = linspace(0.01, 3)*1E-6;
figure
plot(lambda, L_sun(lambda))
xt = get(gca, 'XTick');
set(gca, 'XTick',xt, 'XTickLabel',xt*1E+6)
xlabel('Wavelength (\mum)')
ylabel('Spectral Irradiance (Wm^{-2} \mum^{-1})')
text(1E-6, 1E9, '$\leftarrow L(\lambda) = f_{\nu} \frac{2\pi hc^2}{\lambda^2} \frac{1}{e^{\frac{something}{something else}-1}}$', 'Interpreter','latex', 'HorizontalAlignment','left')
produces:
1Need help flipping axis values - 21019 12 17.png

Produkte


Version

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by