问题
Hi to whole stackoverflow group,
I am having a series of problems when defining the axes range in my graphic and format in general, and I would like to share it with you to see if among all we can find the error
I have found on this website a user who has made it similar. My idea is to have something similar like the graphic of the link below. But for some reason, it's probably silly, it does not appear correctly.
My code is as following:
set term post eps enhanced color "Times-Roman" 14
set output "ComparacionPurezaMetodos.eps"
set key off
set style data histogram
set style histogram cluster gap 1
set style fill solid border -1
set boxwidth 0.8
set xtic rotate by 90 scale 0
unset ytics
set y2tics rotate by 90
set y2label 'Ti_3SiC_2 content, wt{/Symbol\045}' offset -2.5
#set xlabel ' '
set size 0.6, 1
set label 'Powder mixture' at graph 0.5, -0.1 centre rotate by 180
plot 'datos.txt' using 1:(-1):3 with labels rotate right, 'datos.txt' using 1:2 with boxes
and the data are very simple:
# index, purity, name
1 98 Ti/Si/TiC
2 94 Ti/TiSi_2/TiC
3 93.6 Ti/Si/C
4 92 Ti/SiC/TiC
5 93 Ti/SiC/C
6 98 Ti/Si/C + Al
and I expect an output image like figure 4 (pag 6) of chapter 1 of this link: https://books.google.es/books?id=zNWeBQAAQBAJ&printsec=frontcover&hl=es#v=onepage&q&f=false
But my output file does not have to do with this image.
Any idea / help?
Thanks in advance.
回答1:
For your data, you don't need a histogram. Horizontal bars are sufficient. Instead of rotating a graph with plotting style with boxes
you can use the plotting style with boxxyerror
.
Make sure that your data separator is TAB or put your labels into "..."
.
### horizontal bars
reset session
set colorsequence classic
set datafile separator "\t"
$Data <<EOD
# index, purity, name
1 98 Ti/Si/TiC
2 94 Ti/TiSi_2/TiC
3 93.6 Ti/Si/C
4 92 Ti/SiC/TiC
5 93 Ti/SiC/C
6 98 Ti/Si/C + Al
EOD
unset key
set xlabel "Ti_2SiC_2 content, wt%" enhanced
set xrange [90:100]
set ylabel "Powder mixture"
unset ytics
set yrange [0:7]
set style fill solid 1.0
plot $Data u 2:1:(0):2:($1-0.4):($1+0.4):1 with boxxyerror lc variable,\
'' u 2:1:3 with labels offset 1,0 left
### end of code
Result:
来源:https://stackoverflow.com/questions/56021100/how-can-solve-the-code-of-a-rotated-histogram