I am using the epslatex terminal, and I am trying to define specific line styles for my upcoming paper. I created the following styles:
set style line 1 lc rgb '#0060ad' pt 1 lt 1 lw 2 # blue
set style line 2 lc rgb '#dd181f' pt 2 lt 2 lw 2 # red
set style line 3 lc rgb '#ff9933' pt 3 lt 3 lw 2 # orange
set style line 4 lc rgb '#ffcc33' pt 4 lt 4 lw 2 # light orange
set style line 5 lc rgb '#336600' pt 5 lt 5 lw 2 # green
set style line 6 lc rgb '#9900CC' pt 6 lt 6 lw 2 # purple
set style line 7 lc rgb '#000000' pt 7 lt 7 lw 2 # black
However, the moment that I use the following styles in a different Figure, their appearance changes. What can I do to keep my plots' line style standard without changing when using the same terminal? I use lines with points style. Also, I can not change the thickness of the lines in the styles I use.
The standard gnuplot styles are stored somewhere (certainly somewhere in the gnuplot directory) and I am sure you can modify them such that after starting up of gnuplot you will have these as standard styles after gnuplot startup. (check help linestyles vs linetypes).
Anyway, the following is simple and flexible. Simply write your desired styles into a text file and load it during your scripts (check help load).
Style file: SO72347937_Styles.gp
set style line 1 lc rgb '#0060ad' pt 1 lt 1 lw 2 # blue
set style line 2 lc rgb '#dd181f' pt 2 lt 2 lw 2 # red
set style line 3 lc rgb '#ff9933' pt 3 lt 3 lw 2 # orange
set style line 4 lc rgb '#ffcc33' pt 4 lt 4 lw 2 # light orange
set style line 5 lc rgb '#336600' pt 5 lt 5 lw 2 # green
set style line 6 lc rgb '#9900CC' pt 6 lt 6 lw 2 # purple
set style line 7 lc rgb '#000000' pt 7 lt 7 lw 2 # black
Script:
### load custom style file
reset session
load "SO72347937_Styles.gp"
set key top left
set samples 20
plot for [i=1:7] '+' u 1:($1*i) w lp ls i ti sprintf("Style %d",i)
### end of code
Result:
Related
I have created a graph that uses lines for the average of my data and filledcurves for the error (average-error, average+error). My problem is that the last filledcurves that is plotted, covers all other fills, even though I have set its transparency. I want to change this so that when two or more filledcurves meet the color is changed and thus the errors are clearly shown for all lines.
My script is:
set datafile separator whitespace
set style line 1 lc rgb '#aa5500' lt 1 lw 2 pt 7 ps 1
set style line 2 lc rgb '#55aaff' lt 1 lw 2 pt 7 ps 1
set style line 3 lc rgb '#aa557f' lt 1 lw 2 pt 7 ps 1
set style line 4 lc rgb '#55007f' lt 1 lw 2 pt 7 ps 1
set style line 5 lc rgb '#005500' lt 1 lw 2 pt 7 ps 1
set style line 6 lc rgb '#0055ff' lt 1 lw 2 pt 7 ps 1
set tics nomirror
set tics front
set style line 12 lc rgb '#808080' lt 0 lw 1
set grid front ls 12
set output 'network_utilization_servers_3_2.png'
set terminal png size 1000,800
set style fill transparent solid 0.25
set style fill noborder
set xrange[0:77]
set yrange[0:1500]
set xlabel "Time (seconds)" font ",12"
set ylabel "Incoming Traffic (KB/s)" font ",12"
set title "Network Utilization in the Servers" font "Helvetica,16"
set key box title "Server" width 10
plot for [i=0:|Group|-1] $Data3 u ($2-6):($3-$4):($3+$4) index i with filledcurves ls i+1 notitle, \
for [i=0:|Group|-1] $Data3 u ($2-6):3:4 index i w lines ti sprintf("%g",Group[i+1]) ls i+1
and my pragh:
My goal is something like this:
Is there a way to achieve this?
I want to create this histogram with gnuplot:
I used the 6th example from http://gnuplot.sourceforge.net/demo/histograms.html
datafile has the next structure:
Region Austria Hungary ...
1891-1900 234081 181288 ...
1901-1910 668209 808511 ...
...
https://github.com/gnuplot/gnuplot/blob/master/demo/immigration.dat
The minimal script I've got here
http://gnuplot.sourceforge.net/demo/histograms.6.gnu
Is it possible to set the custom color for periods?
Perhaps not the most elegant solution, nevertheless one could prescribe the colors manually by overriding the default linetypes:
set lt 1 lc rgb 'red'
set lt 2 lc rgb 'orange-red'
set lt 3 lc rgb 'orange'
set lt 4 lc rgb 'yellow'
set lt 5 lc rgb 'green'
set lt 6 lc rgb 'blue'
set lt 7 lc rgb 'dark-blue'
set lt 8 lc rgb 'violet'
plot 'immigration.dat' using 6 ti col, '' using 12 ti col, '' using 13 ti col, '' using 14:key(1) ti col
In combination with your minimal script, this produces:
I have been working with gnuplot for a while now. Recently started using it to create reports to send to customers. I tried to experiment with my plotting script but not much has come of it.
My question simply is, how to make charts from Gnuplot look really awesome? Think of D3/chartjs output for comparison.
I understand 'awesome' is subjective. But general pointers in this regard would help a lot!
Look for color palettes that you like online. One nice source is this.
Experiment with border styles, grid styles et cetera.
Once you are happy with it, put the style items in your gnuplotrc.
This is my gnuplotrc:
set encoding utf8
# See https://github.com/Gnuplotting/gnuplot-palettes
# Line styles (colorbrewer Set1)
set style line 1 lc rgb '#E41A1C' pt 1 ps 1 lt 1 lw 2 # red
set style line 2 lc rgb '#377EB8' pt 6 ps 1 lt 1 lw 2 # blue
set style line 3 lc rgb '#4DAF4A' pt 2 ps 1 lt 1 lw 2 # green
set style line 4 lc rgb '#984EA3' pt 3 ps 1 lt 1 lw 2 # purple
set style line 5 lc rgb '#FF7F00' pt 4 ps 1 lt 1 lw 2 # orange
set style line 6 lc rgb '#FFFF33' pt 5 ps 1 lt 1 lw 2 # yellow
set style line 7 lc rgb '#A65628' pt 7 ps 1 lt 1 lw 2 # brown
set style line 8 lc rgb '#F781BF' pt 8 ps 1 lt 1 lw 2 # pink
# Palette
set palette maxcolors 8
set palette defined ( 0 '#E41A1C', 1 '#377EB8', 2 '#4DAF4A', 3 '#984EA3',\
4 '#FF7F00', 5 '#FFFF33', 6 '#A65628', 7 '#F781BF' )
# Standard border
set style line 11 lc rgb '#808080' lt 1 lw 3
set border 0 back ls 11
set tics out nomirror
# Standard grid
set style line 12 lc rgb '#808080' lt 0 lw 1
set grid back ls 12
unset grid
And this is my template for gnuplot files:
set terminal pdfcairo enhanced color dashed font "Alegreya, 14" \
rounded size 16 cm, 9.6 cm
# Default encoding, line styles, pallette, border and grid are set in
# /usr/local/share/gnuplot/x.y/gnuplotrc.
set xlabel "x"
set ylabel "f(x)"
set grid
set key right top
set xrange[0:6.28]
set yrange[-1:1]
set output 'sinx.pdf'
plot sin(x) w l ls 1, cos(x) w l ls 2
(You should change the font to one that you have available.)
It looks like this:
Is this awesome? Well I like to think so! But in all seriousness, there are reasons for this layout.
I want the data to be paramount. That is why the border is not empasized and there is no background color.
Nevertheless, I want the viewer to see where the graph crosses the values shown on the labels, hence the visible tickmarks and (unobtrusive) grid.
To make the graphs "fit" into the style of the document I tend to do a couple of things:
Use the same font as the body text of my documents.
Use the same size, line style, borders et cetera for all the graphs in the document.
Match the graph size to the width of the column or text block.
I want to trace some curves with gnuplot. I recently change my computer and now I have a MacOSX 10.9.5
In my other computer, colors appeared in my .eps figure, but with my Mac not anymore, and an error message appears : "ยท Times not found, using Courier." which is an other problem I think.
My gnuplot version is Version 5.0 patchlevel 0.
Here is my trace.p that I load with gnuplot with
$ gnuplot
gnuplot > load "trace.p"
set autoscale
unset logscale
unset label
set term postscript enhanced 'Times'
set output"E_Hxc_bath_exact_weak.eps"
set title "E^{bath,exact}_{Hxc}/U, E^{bath,weak}_{Hxc}/U functions of U/t with potential more or equal to second-order set to 0"
set xlabel "U/t"
set ylabel "E^{bath}_{Hxc}/U"
set xrange [0.7:10]
set yrange [-7:10]
set key left top
set style line 1 lt 1 lc rgb "red" lw 3
set style line 2 lt 2 lc rgb "red" lw 3
set style line 3 lt 3 lc rgb "red" lw 3
set style line 4 lt 1 lc rgb "green" lw 3
set style line 5 lt 2 lc rgb "green" lw 3
set style line 6 lt 3 lc rgb "green" lw 3
set style line 7 lt 1 lc rgb "black" lw 3
set style line 8 lt 2 lc rgb "black" lw 3
set style line 9 lt 1 lc rgb "blue" lw 3
set style line 10 lt 2 lc rgb "blue" lw 3
set style line 11 lt 3 lc rgb "blue" lw 3
set style line 12 lt 1 lc rgb "violet" lw 3
set style line 13 lt 2 lc rgb "violet" lw 3
plot (0.25 - (3/4)/(sqrt(1+64/(x**2)) + 2*sqrt(1+16/(x**2)))) with lines ls 7 title "exact", (0.25 - 3*(x**2)/64 + (x**3)/(2*16*16)) with lines ls 1 title "weak";
Some lines are certainly useless, but I don't know why the result is colorless, maybe I miss an application or something...
Try adding the color flag to the set term line in your script.
For the dashed lines which didn't appear, it is because in version 5.0, the command change, it is no more linetype but dashtype.
See the response of Gnuplot line types for more precision.
I have the following line styles defined in gnuplot:
set linetype 1 lc rgb "red" lw 3 pt 7
set linetype 3 lc rgb "red" lw 1 pt 7
It appears as though the points derive part of their size from the lineweight. I'm using these styles inside of a plot for loop with linetype cycle using the same style for a cspline and the corresponding points, so I don't see any easy way to just define a separate style for the points.
I get results like this:
The points respond to pointsize but the point in linetype 1 is still slightly larger (presumably from the thicker border).
Is it possible to get the points in these two styles to be the same size?
In response to Miguel's comment, a more complete example of my use case is:
filenames = "A B C D"
set linetype 1 lc rgb "blue" lw 3 pt 7
set linetype 2 lc rgb "red" lw 3 pt 7
set linetype 3 lc rgb "blue" lw 1 pt 7
set linetype 4 lc rgb "red" lw 1 pt 7
set linetype cycle 4
plot for [file in filenames] file.".csv" \
using 1:2
title file \
smooth csplines, \
for [file in filenames] file.".csv" \
u 1:2 with points notitle
linetypes 5-8 get set by the cycling and are used by the last part of the plotting command. Recommendations on another way to do this would be welcome!
For your very specific case you can set more styles, and do it rather automatically with a do for loop (reusing your code):
filenames = "A B C D"
do for [i=0:1] {
set linetype (4*i+1) lc rgb "blue" lw (i == 1 ? 0 : 3) pt 7
set linetype (4*i+2) lc rgb "red" lw (i == 1 ? 0 : 3) pt 7
set linetype (4*i+3) lc rgb "blue" lw (i == 1 ? 0 : 1) pt 7
set linetype (4*i+4) lc rgb "red" lw (i == 1 ? 0 : 1) pt 7
}
set linetype cycle 8
plot for [file in filenames] file.".csv" \
using 1:2 \
title file \
smooth csplines, \
for [file in filenames] file.".csv" \
u 1:2 with points notitle
With some simple data files:
For some terminals the size of filled point types depends on the linewidth because they have a border. This is the case for all cairo-based terminals (pdfcairo, pngcairo, wxt and cairolatex), whereas other terminal like svg, postscript, qt don't show this behaviour.
As test case consider
set linetype 1 lc rgb "red" lw 3 pt 7
set linetype 3 lc rgb "red" lw 1 pt 7
set samples 11
set style function linespoints
plot x lt 1, x + 0.5 lt 3
Considering that you want to have the linepoints samples in the legend, you're best choice is to reduce the point size a bit for the line type with the larger linewidth, like
set linetype 1 lc rgb "red" lw 3 pt 7 ps 0.9
The choice of the scaling factor must be determined manually.