'Gnuplot process no longer responding' when plotting an ascii bar chart with xtics
Hi, I ve been trying to plot a bar chart with some custom labels. here's the data:
data = [[0, 'C1', 3.45],
[1, 'C2', 7.282051282051282],
[2, 'C3', 9.051282051282051],
[3, 'C4', 11.578947368421053],
[4, 'C5', 19.4],
[5, 'S1', 3.727272727272727],
[6, 'S2', 6.523809523809524],
[7, 'S3', 10.285714285714286],
[8, 'S4', 15.0],
[9, 'S5', 19.642857142857142]]
just a simple list. I didn't really know how to use the 'second column' as xtics (in normal GNUplot that would be plot 'data' using 1:3: xtic(2)) so I just used the cmds parameter.
Here's the code:
nums = [el[0] for el in data]
op = [el[2] for el in data]
gp.plot(np.asarray(nums), np.array(op), _with="boxes", cmds="set boxwidth 0.5; set style fill solid; set style line 1 lc rgb 'red'; set xtics ('C1' 0, 'C2' 1, 'C3' 2, 'C4' 3, 'C5' 4, 'S1' 5, 'S2' 6, 'S3' 7, 'S4' 8,'S5' 9)", unset="grid", terminal="dumb")
so here's the thing - the first time it worked and I got this chart (as you can see there I did it wrong then - set xtics ('C1' 1, 'C2' 2, 'C3' 3, 'C4' 4, 'C5' 5, 'S1' 6, 'S2' 7, 'S3' 8, 'S4' 9,'S5' 10) therefore it starts at 1)
20 +-------------------------------------------------------------------+
| + + + **** + + + + * +* |
18 |-+ * * * *-|
| * * * * |
16 |-+ * * * *-|
| * * * * |
| * * ***** * * |
14 |-+ * * * * * *-|
| * * * * * * |
12 |-+ ***** * * * * * *-|
| * * * * * * * * |
10 |-+ * * * * ***** * * * *-|
| ***** * * * * * * * * * * |
8 |-+ * * * * * * * * * * * *-|
| **** * * * * * * * * * * * * |
| * * * * * * * * **** * * * * * * |
6 |-+ * * * * * * * * * * * * * * * *-|
| * * * * * * * * * * * * * * * * |
4 |-**** * * * * * * * * **** * * * * * * * *-|
| * * *+ * * + * * + * * +* *+ * *+ * * + * * + * * +* |
2 +-------------------------------------------------------------------+
C1 C2 C3 C4 C5 S1 S2 S3 S4
but when I tried to do this again after some time but not from terminal but in the script it not only didn't work in the script/file but also stopped working in terminal.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gnuplotlib.py", line 2654, in plot
globalplot.plot(*curves)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gnuplotlib.py", line 2529, in plot
self._safelyWriteToPipe(subplotOptionsCmds)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gnuplotlib.py", line 1612, in _safelyWriteToPipe
errorMessage, warnings = self._checkpoint('printwarnings')
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/gnuplotlib.py", line 1720, in _checkpoint
and/or gnuplot itself. Please report this as a gnuplotlib bug''')
gnuplotlib.GnuplotlibError: Gnuplot process no longer responding. This is likely a bug in gnuplotlib
and/or gnuplot itself. Please report this as a gnuplotlib bug
Reseting python and GNUplot didn't do the trick and the traceback asked me to report this so voilà
Hi. Thanks for the report. I'm not sure how to try to reproduce this given what you told me. You put that plot command into a script, and it consistently gives you that error? Can I get a copy of the script?
I did it again later and it worked that time and I am quite confused myself now since I've had been trying everything back then to get it running. Somehow trying the next day helped so I guess the source of the issue might be some bug in gnuplot itself? I dunno really and there's really nothing to add. the script is like so:
nums = [el[0] for el in data]
op = [el[2] for el in data]
gp.plot(np.asarray(nums), np.array(op), _with="boxes",
cmds="set boxwidth 0.5; set style fill solid; set style line 1 lc rgb 'red'; set xtics ('C1' 0, 'C2' 1, 'C3' 2, 'C4' 3, 'C5' 4, 'S1' 5, 'S2' 6, 'S3' 7, 'S4' 8,'S5' 9)",
unset="grid", terminal="dumb")
and here's my terminal after executing it:
20 +---------------------------------------------------------------------+
| + + + + **** + + + + * +* |
18 |-+ * * * *-|
| * * * * |
16 |-+ * * * *-|
| * * * * |
| * * **** * * |
14 |-+ * * * * * *-|
| * * * * * * |
12 |-+ **** * * * * * *-|
| * * * * * * * * |
10 |-+ * * * * **** * * * *-|
| **** * * * * * * * * * * |
8 |-+ * * * * * * * * * * * *-|
| **** * * * * * * * * * * * * |
| * * * * * * * * **** * * * * * * |
6 |-+ * * * * * * * * * * * * * * * *-|
| * * * * * * * * * * * * * * * * |
4 |-**** * * * * * * * * **** * * * * * * * *-|
| * +* * +* * +* * +* * +* * +* * +* * +* * +* * +* |
2 +---------------------------------------------------------------------+
C1 C2 C3 C4 C5 S1 S2 S3 S4 S5
>>> data
data
[[0, 'C1', 3.45], [1, 'C2', 7.282051282051282], [2, 'C3', 9.051282051282051], [3, 'C4', 11.578947368421053], [4, 'C5', 19.4], [5, 'S1', 3.727272727272727], [6, 'S2', 6.523809523809524], [7, 'S3', 10.285714285714286], [8, 'S4', 15.0], [9, 'S5', 19.642857142857142]]
>>> nums
nums
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> op
op
[3.45, 7.282051282051282, 9.051282051282051, 11.578947368421053, 19.4, 3.727272727272727, 6.523809523809524, 10.285714285714286, 15.0, 19.642857142857142]
and that's all
OK. If you find a reproducible case, ping me. I'm going to at least document giving arbitrary labels to columns in the near future. It should be doable in at least slightly less clunky way than what you're having to do.
Need more info, so I'm closing this. Today there's no way to eliminate failures like this 100%, but I can try to make specific cases work better, if people send me reports.