Can I have two different y axis for the same dataset?
Show older comments
INTRODUCTION:
I need to create a plot of the noise performance of the readout electronics for a radiation detector, with respect to a circuit-related parameter called "peaking time".
In our scientific community, some people express this noise in term of "ENC" (equivalent noise charge), others in term of "FWHM" (full width at half maximum of a gaussian, in electron-volt).
So, the same noise performance can be expressed with two different numbers. There is a univocal relationship (non-linear) between ENC and FWHM.
QUESTION:
In my case I therefore wish to have a single plot, where on the x-axis I plot a parameter called "peaking time" and on the y-axis I plot the noise performance. I want to to have the ENC ticks on the left y axis, and the FWHM ticks on the right y axis. Note: I do not want to have two plotted curves, just one.
Any suggestion on how to do this?
Thank you very much
Paolo
Answers (1)
2 Comments
Paolo Trigilio
on 1 Dec 2018
Edited: Paolo Trigilio
on 1 Dec 2018
Adam Danz
on 1 Dec 2018
You can use yyaxis to do what you're describing. You don't need to plot a 2nd set of data. Just use the right axis for scaling and setting the y ticks you want. Here's an example.
x = 1:10;
y = log(x);
plot(x,y, '-o')
h = gca;
yyaxis left
set(h, 'YTick', [0 : .5 : 3], 'ylim', [0, 3])
leftColor = h.YAxis.Color;
yyaxis right
set(gca, 'YTick', [0 : .25: 1], 'ylim', [0, 1])
h.YAxis(2).Color = leftColor;
Categories
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!