Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plot vertical graphs, gnuplot. Rotate xlabel and key

First of all I would like to apologize for the text, my English is a bit rusty.

So I have a problem plotting a chart and it's been a long time consuming. The chart is below.

This graph is generated from a fit of a normal distribution relative to a data file.

I wanted to plot the gaussians at y, not at x. Make these chart vertical. I researched several things and did not find it. Then I had the idea of ​​rotating it in \TeX, but for that I would have to turn the labels, the tics, and the key.

I use epslatex, so I had issues with transparency. I solved this problem using cairolatex (which generated the figure below). Resolved the transparency, I went to turn all tics and the labels.

First question, how does xlabel spin, I did set xlabel '$E_p [meV]$' rotate by 180 and it did not work, so my solution was to make a unset xlabel set label '$E_p$ [meV]' at 30.5,-550 rotate by 180 and adjust the position, which is nothing practical.

The second question, of which I did not find any solution is, how to turn the key?

Follow the figures for a better understanding ...

Thank you...

enter image description here

enter image description here

enter image description here

like image 689
benjamin_ee Avatar asked Jan 29 '26 21:01

benjamin_ee


1 Answers

You can use set parametric to plot such functions which cannot be written as y(x). In the parametric mode you must specify functions x(t) and y(t) for both coordinates. The range of the dummy variable t is controlled by set trange. A simple example is

set parametric
set trange [-4:4]
set autoscale yfix
y(t) = t
x(t) = t**2
plot x(t), y(t) with lines 

Here, the set autoscale yfix automatically adjusts the yrange to the range of y(t), which is desired in this case. The xrange is autoscaled as usual.

enter image description here

So, an extension of the above example for gaussians with some eye candy could be

reset
set samples 1000
set style fill  transparent solid 0.50 noborder
set style function filledcurves x1=0
set xlabel "Counts"
set ylabel "Energy"
Gauss(x,mu,sigma) = 1./(sigma*sqrt(2*pi)) * exp( -(x-mu)**2 / (2*sigma**2) )
d1(x) = Gauss(x, 0.5, 0.5)
d2(x) = Gauss(x,  2.,  1.)
d3(x) = Gauss(x, -1.,  2.)
set encoding utf8
set parametric
set trange [-8:8]
set autoscale yfix
plot d1(t),t title "μ =  0.5 σ = 0.5",\
     d2(t),t title "μ =  2.0 σ = 1.0",\
     d3(t),t title "μ = -1.0 σ = 2.0"

enter image description here

like image 66
Christoph Avatar answered Feb 01 '26 14:02

Christoph



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!