开发者

Gnuplot : xtics - place strings at tics

开发者 https://www.devze.com 2023-02-10 16:08 出处:网络
I am new to gnuplot, and am t开发者_如何学编程rying to create a stacked histogram for a project. The problem I am running into is, that I am not able to put ticlabels on the x-axis (even if I could, t

I am new to gnuplot, and am t开发者_如何学编程rying to create a stacked histogram for a project. The problem I am running into is, that I am not able to put ticlabels on the x-axis (even if I could, they are not getting formatted in a neat way). My gp file is as follows:

Here is a snapshot of my data file:

CC P1-X P1-Y P2-X P2-Y
1 0.1097586  0.3262812  1.980848  5.9098402
2 0.1010986  0.2988812  0.9966702  5.8378412
3 0.4017474  0.7559452  4.41813  11.7404132
4 0.1028442  0.2974772  1.418744  6.0554552
5 0.1097316  0.3216112  1.967492  5.8007364
6 0.954794  0.3004874  0.9568386  5.778537

And here is my gp file:

set title "GCC compilation option by average execution time as stacked histogram"
set terminal jpeg medium
set output "histosmalldata.jpeg"
set boxwidth 0.9 absolute
set style fill solid 1.00 border -1
set key autotitle columnheader
set key outside right top vertical Left reverse enhanced autotitles columnhead nobox
set key invert samplen 4 spacing 1 width 0 height 0 
set style histogram rowstacked title  offset character 0, 0, 0
set style data histograms
set xtics border in scale 1,0.5 nomirror rotate by -45  offset character 0, 0, 0
set xtics norangelimit
set xtics ("O2-ffast-math-finline-functions" 1, "O2-funroll-loops-march=barcelona-ffast-math-finline-functions" 2, "GCCFLAGS_O0" 3, "O2-ftree-vectorize-funroll-loops-march=barcelona" 4, "GCCFLAGS_O2" 5, "O2-ftree-vectorize-funroll-loops-ffast-math" 6)
set xtics 1,6 nomirror 
set ytics 0,100 nomirror
set ytics 1
set yrange [0:20]
set ylabel "Time"
set xlabel "GCC Compiler Options"
plot 'smalldata' using 2:xtic(1) ti col, '' using 3 ti col, '' using 4 ti col, '' using 5 ti col

This is the image of the graph:

Gnuplot : xtics - place strings at tics

Now, in the x axis, I am having 1,2,3 - 6 which I don't want, instead, I would want "O2-ffast-math-finline-functions" for 1 and so on in a neat formatted way.

I wrote this script after consulting some examples from gnuplot page and do not have a good understanding of some of the verbs, so apart from the solution, any general comments are welcome.

Thank you,

Sayan


You should not overwrite your xtics settings after you specified what you want.

Put all options into a single set command:

set xtics border in scale 1,0.5 nomirror rotate by -45  offset character 0, 0, 0\
         norangelimit\
         ("O2-ffast-math-finline-functions" 1,\
          "O2-funroll-loops-march=barcelona-ffast-math-finline-functions" 2,\
          "GCCFLAGS_O0" 3, "O2-ftree-vectorize-funroll-loops-march=barcelona" 4,\
          "GCCFLAGS_O2" 5, "O2-ftree-vectorize-funroll-loops-ffast-math" 6)

Note that you can escape the newline with a backslash as the last character of the line.


I figured out, that I do not actually need to specify ticlabels because that information is in my source file. So I modified my source file like:

set title "GCC compilation option by average execution time as stacked histogram"
set terminal png size 1500,1200 font "/Library/Fonts/Times New Roman Bold.ttf, 13"
set output 'hist_gcc_1.png'
set boxwidth 0.9 absolute
set style fill solid 1.00 border -1
set key outside right top vertical Left reverse enhanced autotitles columnhead nobox
set key invert samplen 4 spacing 1 width 0 height 0 
set style histogram rowstacked title offset character 0, 0, 0
set datafile missing '-' 
set style data histograms
set xtics border in scale 1,0.5 nomirror rotate by -45 offset character 0, 0, 0     norangelimit
set ytics 0,100 nomirror
set ytics 1
set yrange [0:20]
set ylabel "Time"
set xlabel "GCC Compiler Options"
plot 'data' using 2:xticlabels(1) ti col, '' using 3 ti col, '' using 4 ti col, '' using 5 ti col

My dat file looks like:

CC P1-X P1-Y P2-X P2-Y
O2-ffast-math-finline-functions 0.1097586  0.3262812  1.980848 5.9098402
O2-funroll-loops-march=barcelona-ffast-math-finline-functions 0.1010986 0.2988812  0.9966702 5.8378412
GCCFLAGS_O0 0.4017474 0.7559452 4.41813 11.7404132
...
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号