Problem statement:
I am using qt term in gunplot to do a few graphs, however I get the following bug: the display window comes up for a microsecond and disappears, whereas terminal spits out the following: 'qt.qpa.fonts: Populating font family aliases took 260 ms. Replace uses of missing font family "Sans" with one that exists to avoid this cost.' -- Option 1.0 in code below
What I've tried:
Tried multiple fixes, involving change of font i.e Option 1.1 in code below. Upon changing to Helvetica or Verdana, the error disappears, but there is no display window.
Any ideas on how to fix it?
So far, I can get the graphs saved using the png term -- Option 1.2, all other term seem to produce same error as with qt. Desired solution is to have a functional display window as to avoid opening the saved.png.
P.S Using Mac OS, version 10.15.4 Catalina. Same code used to work before on older OS and older version of Gnuplot with x11/aquaterm support, which is not supported by the current OS and brew install.
Thank you all in advance!!!
Some Code (gunplot zsh script attached below):
gnuplot << EOF
# Option 1.0
set terminal qt
# does Error in commant prompt: qt.qpa.fonts: Populating font family aliases took 252 ms. Replace uses of missing font family "Sans" with one that exists to avoid this cost.
# Option 1.1
#set terminal qt font "Helvetica" # does no error in command prompt, no window displayed
# Option 1.2
#set terminal png
#set output 'saved.png' # saves .png but no window generated
# PARKER WIND
set xr [0.5:2.0]
set yr [0.0:2.5]
set xlabel "r/r_0"
set ylabel "Psi"
set style line 1 lt 1 lc rgb "blue" lw 1 pt 11
set style line 2 lt 1 lc rgb "black" lw 1 pt 11
set style line 3 lt 1 lc rgb "black" lw 1 pt 7 ps 2
set style line 4 lt 1 lc rgb "blue" lw 1 pt 7 ps 2
set style line 5 lt 1 lc rgb "black" lw 3 pt 7 ps 2
set xzeroaxis
# MULTIPLE GRAPHS
plot 'outputdata/parker_0.500.dat' u 1:2 with lines ls 1 title "psi0=0.500" ,\
'outputdata/parker_0.550.dat' u 1:2 with lines ls 1 title "psi0=0.550" ,\
'outputdata/parker_0.600.dat' u 1:2 with lines ls 1 title "psi0=0.600" ,\
'outputdata/parker_0.650.dat' u 1:2 with lines ls 1 title "psi0=0.650" ,\
'outputdata/parker_0.700.dat' u 1:2 with lines ls 1 title "psi0=0.700" ,\
'outputdata/parker_0.750.dat' u 1:2 with lines ls 1 title "psi0=0.750" ,\
'outputdata/parker_0.800.dat' u 1:2 with lines ls 1 title "psi0=0.800" ,\
'outputdata/parker_0.850.dat' u 1:2 with lines ls 1 title "psi0=0.850" ,\
EOF
You need to tell gnuplot to "persist" your plot with the -p option:
gnuplot -p <<EOF
...
...
EOF
You might also consider adding the following to your login script to always select qt output:
export GNUTERM=qt
Related
Currently, I have a text file and I'm interested in plotting two different curves from a single file(values for x axis are the same-column 1, values for y axis-columns 3 and 4). The plot should be in STDOUT since I'm working from ssh. The file that I am working with looks like this (filename: tmp)
%Iter duration train_objective valid_objective difference
0 6.0 0.0195735 0.0610958 0.0415223
1 5.0 0.180216 0.191344 0.011128
2 5.0 0.223318 0.241081 0.017763
3 6.0 0.245895 0.262197 0.016302
4 6.0 0.25796 0.28056 0.0226
5 6.0 0.269223 0.291769 0.022546
6 5.0 0.281187 0.298474 0.017287
7 5.0 0.283891 0.305579 0.021688
8 5.0 0.296456 0.307381 0.010925
9 5.0 0.296856 0.315487 0.018631
10 5.0 0.295805 0.321391 0.025586
Total training time is 0:06:27
So far, I can only plot the values corresponding to the 3rd column using the following line:
cat tmp | gnuplot -e "set terminal dumb size 120, 30; set autoscale; plot '-' u 1:3 with lines notitle"
Could someone tell me then how I could include the 4th column in the same plot? is that possible?
Thanks!
There is nothing in your description that rules out the trivial answer:
gnuplot -e "plot 'tmp' u 1:3 with lines, '' u 1:4 with lines"
The terminal choice is not relevant (you used 'set term dumb' but it could just as easily be any other output terminal, connection via ssh does not prevent that). If you have additional constraints that require a more complicated solution, please add them to the question.
I switched from Windows cmd terminal to bash in PhpStorm and now when I run Symfony CLI commands like server:start it shows characters like ?[30;43m instead of a formatted text.
I tried these Symfony commands on both PhpStorm and Visual studio code with the same results. It did work on git bash terminal though.
Here a screenshot from PhpStorm executing server:start:
and a screenshot using Windows cmd for the same command:
Do you know how to solve this problem?
My solution
I left Windows to Linux. Now everything works fine. I could not make it work properly on Windows though.
I think the ? means that my terminal on windows had trouble with the escape character used to interpret the formatting code [30;43m.
Here is my homemade explanation of this kind of formatting code:
Use echo -e to use text formatting.
Syntaxe:
\e[FORMAT;FORMAT;FORMATm
\e is the escape character (\033 works too).
[ mark the beginning of the format code.
; separate formating code sequence.
m mark the end of the format code.
FORMAT has to be replaced by a formatting code:
character effects using 1 digit:
code | effect
---- | ------
0 | normal
1 | bold
4 | underlined
5 | blinking
7 | reverse colors
colors using 2 digit:
first digit (the target):
code | effect
---- | ------
3 | foreground
4 | background
second digit (the color):
code | effect
---- | ------
0 | black
1 | red
2 | green
3 | brown
4 | blue
5 | purple
6 | cyan
7 | light gray
These are color codes, from the ANSI Escape codes : https://en.wikipedia.org/wiki/ANSI_escape_code
Some terminals use these codes to apply text formatting, while others just display them as regular text. Most programs that print such codes in an attempt to color their output also have an option to silence them, in order to make the display more readable on dumber terminals.
I think we were using gnuplot for decades. But still there is no good way to get a good video output from gnuplot, am I right? What I did is made around 30,000 images (I had to make it with good quality too, to get video clarity), then used ffmpeg to make the video:
ffmpeg -f image2 -r 10.0 -i capture.%d.png -qscale 1 filename.mp4
But some time I get stuck in between or it takes too long time. We may always need a video output with high quality and low file size, why no one is attempting to do anything, or is there any other method to make video out put from gnuplot? I am really struggling to make high quality videos with gnuplot.
You can pipe the output of gnuplot directly to ffmpeg without storing the images on the hard drive. For that you need to tell ffmpeg what format and resolution it has to expect from the pipe, since it can not guess it alone from the extension etc. now. Here is an example:
gnuplot animation.plt | ffmpeg -f png_pipe -s:v 800x600 -i pipe: out.mp4
I used the code from here with some minor modifications.
animation.plt
#!/usr/bin/gnuplot
#
# Creating an animation gif of the Bessel function
# NOTE: this files creates multiple png images, the gif file is then created
# using GIMP
#
# AUTHOR: Hagen Wierstorf
reset
set terminal pngcairo size 800,600 enhanced font 'Verdana,10'
# color definitions
set palette rgb 3,9,9
unset key; unset colorbox; unset border; unset tics
set lmargin at screen 0.03
set bmargin at screen 0
set rmargin at screen 0.97
set tmargin at screen 1
set parametric
# Bessel function, which is moving in time
bessel(x,t) = besj0(x) * cos(2*pi*t)
# calculate the zeros for the bessel function (see Watson, "A Treatise on the
# Theory of Bessel Functions", 1966, page 505)
n = 6 # number of zeros
k = (n*pi-1.0/4*pi)
u_0 = k + 1/(8*k) - 31/(384*k)**3 + 3779/(15360*k)**5
set urange [0:u_0]
set vrange[0:1.5*pi]
set cbrange [-1:1]
set zrange[-1:1]
set isosamples 200,100
set pm3d depthorder
set view 40,200
# initializing values for the loop and start the loop
t = 0
end_time = 1
#system('mkdir -p animation')
load 'bessel.plt'
bessel.plt
# bessel loop
t = t + 0.02
#outfile = sprintf('animation/bessel%03.0f.png',50*t)
#set output outfile
splot u*sin(v),u*cos(v),bessel(u,t) w pm3d ls 1
if(t<end_time) reread;
Gives you a video which looks like this. (This is downscaled and transcoded gif just for demo purposes)
You can also play around with ffmpeg encoder parameters. here only default video encoder config is used.
Gnuplot with the pdfcairo terminal seems to give strange behavior in terms of fonts, where the generated pdf has unnamed, Type 3 fonts. Here's output from pdffonts on the output pdf file:
name type encoding emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
[none] Type 3 Custom yes no yes 5 0
HTVMTJ+Helvetica CID TrueType Identity-H yes yes yes 6 0
ITRAZO+Helvetica CID TrueType Identity-H yes yes yes 7 0
This is a problem because the publisher refuses to accept Type 3 fonts in documents. How do I get around this? Below is a small gnuplot file that reproduces the problem on OS X El Capitan 10.11.3, gnuplot 5.0 patchlevel 5:
set terminal pdfcairo font "Helvetica, 16"
set output "../plots/test.pdf"
set xlabel "x-axis"
set ylabel "y-axis"
set xrange [0:1]
set yrange [0:1]
plot 0.5 title "y=0.5" w l lw 3
For now, my workaround is to use the postscript terminal and then epstopdf, but this requires a lot of rework on many many scripts. Any ideas what's wrong here?
I've hit this issue too and narrowed it down to being spaces. Any time you add whitespace to an axis label or set the tic format to include space, you get an unnamed Type 3 font added. I can't even begin to understand why.
I am trying to use the for syntax for multiple columns.
I have a data file colhead.dat:
Id a1 a2 a3
1 1 2 3
2 2 3 4
3 2 3 4
Following the answer https://stackoverflow.com/a/17525615/429850, I do
gnuplot> plot for [i=2:5] 'colhead.dat' u 1:i w lp title columnheader(i)
^
':' expected
How do i write the for loop? Here's the gnuplot version header
Version 4.2 patchlevel 6
last modified Sep 2009
System: Linux 2.6.32-71.el6.x86_64
For-loops have been implemented in version 4.6 of gnuplot, and there was nothing like loops in the versions before. So you have to update your version!
Edit: As Christoph mentioned, first for functionality was introduced in 4.4. However, 4.2 is too old.