gnuplot postscript terminal not showing transparent symbols - gnuplot

Hopefully, this is a stupid question, and easy to fix. When I run this simple gnuplot script:
#!/usr/bin/env gnuplot
set term png
set out "out.png"
plot "<jot -r -p 2 500 1 2" not w p pt 7 ps 4 lc rgb "#908DB6CD"
set term post eps enhanced color
set out "out.eps"
replot
exit
The png file looks like this:
And the eps looks like this:
The pdfcairo terminal also gives me transparency. Any clues on how to make the eps files show transparency?
Many thanks in advance!

I think I should respond to my own question, so at least this becomes a case closed.
After some more digging, and from the comments I received, the bottom line is that the gnuplot postscript terminal does not handle transparency, while the pdf and pdfcairo terminals do.
The trick is to generate an .eps file from a .pdf using pdftops:
#!/bin/bash
gnuplot << GNU
set term pdf
set out "out.pdf"
plot "<jot -r -p 2 500 1 2" not w p pt 7 ps 4 lc rgb "#908DB6CD"
GNU
pdftops -eps out.pdf
All of my .eps files are generated to be incorporated to LaTeX documents. Then, I could just switch to PDFLaTeX and be over with it. However, at times I like to edit the .eps to tweak the bounding box and other things by hand or using awk/sed. Anyway, hope this is helpful.

Related

Gnuplot Postscript Special Characters Math Equation

I`d like to write the math stuff into a plot using gnuplot 5:
I am using the terminal postscript enhanced because as far as I know this terminal is the only only capable of doing such things.
I used this code:
set label 1 at 400,200 '{/Symbol=50\362#_{/=15 350}^{/=15\154}}' front
This gets me everything except the subscribed averageunder the lambda symbol.
I tried everything with {,}and so on but I think I missing the part where I can escape the /SymbolStyle.
Many terminals support enhanced text, not only the postscript terminal.
In order to use another font than /Symbol for the subscript you could change the font explicitely to a different one for this. However, a better approach is to change the nesting so that /Symbol affects only two parts:
set label 1 at 0,0 '{/=50{/Symbol \362}#_{/=15 350}^{/=15{/Symbol \154}_{/=10 average}}' front
plot x
Output with gnuplot 5.0 with wxt is
If you're using the postscript terminal anyway, you could give a try to the epslatex terminal (or cairolatex):
set terminal epslatex standalone color colortext
set output 'equation.tex'
set label 1 at -5,5 '$\displaystyle\int_{350}^{\lambda_{\mathrm{average}}}$'
plot x
set output
system('latex equation.tex')
system('dvips equation.dvi')
system('ps2pdf equation.ps')

Gnuplot shows garbage when trying to save picture

When I input the following into the gnuplot window:
set xlabel "x"; set ylabel "y";
plot "rk1000.dat" with lines, "teor1000.dat" with lines
The result is a nice plot. However, when I attempt to save it as a .png file, the result is not so nice. After typing
set xlabel "x"; set ylabel "y"; set terminal png size 800,600;
plot "rk1000.dat" with lines, "teor1000.dat" with lines
the result is gnuplot spitting out garbage characters and doing nothing. Here's a screenshot:
How do I fix this? Not even an hour ago I had no problem saving my plots.
You can use set output in your script to make gnuplot redirect the output to a file:
set terminal png size 800,600
set output "plot.png"
plot "rk1000.dat" with lines, "teor1000.dat" with lines
If you are creating png images using gnuplot, the "pngcairo" terminal produces better-looking results. Try set terminal to see the list of available terminals.
Just save the output to a png file:
gnuplot script.gp > picture.png
Search the web for "redirection" if you want to know more.
you should plot first then set term
ex
"plot '../log/test_coverage_${atpg_mode}.log.tmp' title 'Ori ATPG' w lp lt 3 pt 9"
"set terminal png font \"/usr/share/fonts/liberation/LiberationSerif-Italic.ttf\" 9" ; # save the image as the png format
"set terminal png size 1000, 800" ; # save the image size as 800*1000
"set output '${REPORT_DIR}/Test_Coverage_Curve_${atpg_mode}.png'"
"replot"

Two interactive windows in Gnuplot with wxt terminal

I often use the wxt terminal of Gnuplot to do some quick data inspection. I like the interactivity, such that I can easily gain control and zoom/move et cetera.
Suppose I have to following script
set terminal wxt 0 persist
plot x
set terminal wxt 1 persist
plot x**2
Now, on window 1 I have the interactive control. However, on window 0 this interactive control is lost.
My question is: How can I obtain interactive control on window 0?
I am using gnuplot 4.6.2. I've seen gnuplot multiple graphs are not interactive but the question in about x11 terminal, and the answers consist of opening multiple instance of gnuplot, which seems unnecessary to me.
I believe have found a workaround for this problem.
But not sure if this works for all cases.
My solution sounds like obvious.
I created three files: configs.plt, wxt1.plt, and wxt2.plt.
The configs.plt file contains:
set style line 1 lc "#e41a1c"
set style line 2 lc "#377eb8"
The wxt1.plt file contains:
set terminal wxt title "plot sin"
load "configs.plt"
plot sin(x) w l ls 1
The wxt2.plt file contains:
set terminal wxt title "plot cos"
load "configs.plt"
plot cos(x) w l ls 2
The only boring thing is run two instead one file.

bold enhanced text in gnuplot

UPDATE: this issue has been resolved in newer versions (>5.0) of gnuplot; see #andyras' answer.
I am having difficulty getting gnuplot to create labels with bold and enhanced text in non-postscript terminals. The following script
#!/usr/bin/env gnuplot
reset
set terminal pdfcairo enhanced color lw 3 size 3,2 font 'Arial-Bold'
set output 'output.pdf'
set tics scale 0
plot -x title 'normal text', \
-2*x t 'enhanced_{text}', \
-3*x t '{/Arial-Bold attempt to specify_{font}}'
set terminal pngcairo enhanced color lw 3 size 400,300 font 'Arial-Bold'
set output 'output.png'
replot
set terminal postscript enhanced color lw 3 size 6,4 font 'Arial-Bold'
set output 'output.eps'
replot
reset
Produces the following eps (converted to png with convert output.eps -rotate 90 outputeps.png):
which is fine. However, when I use the pdf or png terminals the result looks like this:
Note that while all the label text should be bold, only the label without any enhanced text is bold. In addition, when I try to manually specify the font (last line title) the font is different (reverts to the default?).
Is this behavior I should expect when not using the postscript terminal? Is there another way to specify fonts (i.e. is the naming scheme different outside of postscript)?
Since version 5.0, gnuplot has a new syntax to handle this issue:
"normal text {/Times:Bold boldface-newfont} {/:Italic slanted-default-font } back to normal text"]
These brackets can also be nested.
For Better results in pdf format.
Plot the curves using enhanced eps terminal. Then use Imagemagic to convert your output to pdf format. using the commands
convert myPlot.eps myPlot.pdf
Default resolution with this commands generates a poor output. This can be overcome by using density option with a value of 300. Modified command looks like
convert -density 300 myPlot.eps myPlot.pdf
I found that this preserves all the text formatting of eps file in pdf file.

Gnuplot dot dash

Hi guys I'm using Windows and I'm trying to get something done in Gnuplot. I need to set the line style of my graph as dot dash.
http://sparky.rice.edu/gnuplot.html tells me that:
Differs from x11 to postscript
lt chooses a particular line type: -1=black 1=red 2=grn 3=blue 4=purple 5=aqua 6=brn 7=orange 8=light-brn
lt must be specified before pt for colored points
for postscipt -1=normal, 1=grey, 2=dashed, 3=hashed, 4=dot, 5=dot-dash
What does he mean by postscript here? How can I achieve this? I've been trying many times to plot my graph using the command:
plot 'graph1.txt' with lines lt 5 but I don't get the dot-dash line.
Help would be immensely appreciated!
This means that the values given for lt only work when you are plotting to a Postscript file, and will not work if you plot in a window in the straightforward way. Simplest thing would be to plot to a Postscript file using
set term postscript
set output "file.ps"
The plot will be in file.ps.

Resources