3

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

benjamin_ee
  • 153
  • 4

1 Answers1

4

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

Christoph
  • 47,569
  • 8
  • 87
  • 187
  • The solution you presented is very good. He solved my problem, very quickly. With set sample 1000 it was half grid, I increased it to 20000 to be cool, only appeared white lines, very discreet. – benjamin_ee Feb 24 '18 at 12:28
  • With version 5.2 you shouldn't get any white lines. That was a problem with filledcurves in previous versions. – Christoph Feb 24 '18 at 14:01