You are not logged in.
Hi
I am doing a rowstacked histogram in gnuplot using data from a file I have created.
The values on the x axis however do not reflect the labels from the first column of the file.
The data file "energisystemetiaktivitet" looks like this:
#Distanse(m) Aerob(ml02/kg/min) Anaerob(mlO2/kg/min)
200 33 7
400 39 31
800 50 100
1500 50 250
The gnuplot code looks like this:
set term tikz standalone monochrome
set size 1.1, 1.1
set output "test.tex"
set title "Bruk av Energisystmener i Aktivitet" font ",14"
show title
set xlabel "Distance (m)"
set ylabel "Energi forbruk (mlO2/kg/min)"
set xtics scale -1,-0.5
set ytics scale -1,-0.5
set border 3
set boxwidth 0.75 absolute
set style data histograms
set bars fullwidth
set style fill solid 1.0 border -1
set xtics nomirror
set ytics nomirror
set yrange [0:350]
set style histogram rowstacked
plot "energisystemetiaktivitet" using 2 fs solid 1.00 lt -1 title 'Anaerob', '' using 3 fs solid 0.00 lt -1 title 'Aerob'
The x axis should show 200, 400, 800, and 1500 for each column respectively but instead I get 0, 1, 2, and 3.
Can someone tell me what I am doing wrong?
Cheers,
BTW: I am using the TiKz terminal to make a .tex file, which I running through pdflatex.
Last edited by Hantabaru (2011-12-21 14:15:43)
Offline
The idea of using tikz is pretty nice, i should try this one too. can you just include the tex output as kind of graphics into a floating texdocument ?
how does it behave when setting the xrange to [-1,801] ?
Offline
The idea of using tikz is pretty nice, i should try this one too. can you just include the tex output as kind of graphics into a floating texdocument ?
The tex output can be either standalone or a tex file that you can cut and paste, or \input{}, into your LaTeX document.
how does it behave when setting the xrange to [-1,801] ?
This just causes the columns to be extremely thin and pushed way over towards the y axis -> This suggests the x axis is acting as a scale and not 'categories' or groups
Any ideas?
Offline
Hantabaru, I only dabbled in gnuplot for a bit before I realized 'R' would do everything I needed/wanted easier including plotting to a pdf. Have you considered using R? A 4 line script would do the job for this plot.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
From what I have read in the gnuplot manual it the xticlabels option I need to set in the line beginning 'plot', so:
set term tikz standalone monochrome
set size 1.1, 1.1
set output "test.tex"
set title "Bruk av Energisystmener i Aktivitet" font ",14"
show title
set xlabel "Distance (m)"
set ylabel "Energi forbruk (mlO2/kg/min)"
set xtics scale -1,-0.5
set ytics scale -1,-0.5
set border 3
set boxwidth 0.75 absolute
set style data histograms
set bars fullwidth
set style fill solid 1.0 border -1
set xtics nomirror
set ytics nomirror
set yrange [0:350]
set style histogram rowstacked
plot "energisystemetiaktivitet" using 2:xticlabels(1) fs solid 1.00 lt -1 title 'Anaerob', '' using 3 fs solid 0.00 lt -1 title 'Aerob'
...should work.
But I get
plot "energisystemetiaktivitet" using 2:xticlabels(1) solid 1.00 lt -1 title 'Anaerob', '' using 3 fs solid 0.00 lt -1 title 'Aerob'
^
"anaerob_aerob_gnuplot", line 18: ';' expected
I am not sure what I am doing wrong.
Offline
Hantabaru, I only dabbled in gnuplot for a bit before I realized 'R' would do everything I needed/wanted easier including plotting to a pdf. Have you considered using R? A 4 line script would do the job for this plot.
Yes, have used R a fair bit but I wanted to try with gnuplot seeing as I have hear from several people that it is a useful tool to use inconjunction with LaTeX and R.
Plus I liked the fact I can produce the graph in TiKz code :-)
So this is a bit of a learning project for me :-)
Offline
Ok, so I managed to sort it out.
The following gave me the graph with the x axis labelled correctly.
set term tikz standalone monochrome
set size 1.1, 1.1
set output "test.tex"
# set title "Bruk av Energisystmener i Aktivitet" font ",14"
# show title
set xlabel "Distance (m)"
set ylabel "Energi forbruk (mlO2/kg/min)"
set xtics scale -1,-0.5
set ytics scale -1,-0.5
set border 3
set boxwidth 0.75 absolute
set style data histograms
set bars fullwidth
set style fill solid 1.0 border -1
set xtics nomirror
set ytics nomirror
set yrange [0:350]
set style histogram rowstacked
plot "energisystemetiaktivitet" using 2:xticlabels(1) fs solid 1.00 lt -1 title 'Anaerob', '' using 3 fs solid 0.00 lt -1 title 'Aerob'
Note: The :xticlabels(1) option can be added to either of the 'using' parts of the plot command (Here I've added it to 2).
You can also use :xtic(1) if you are lazy :-)
There error was a bit spurious. When I undid everything and tried again it worked, so probably a typo or something....
Offline