|
From: Bernhard H. <b.h...@fz...> - 2015-12-22 16:28:43
|
Hey! Thank you for your reply! In the meantime I was able to solve the issue and I of course will share it with you:
One can use the set_option(with_= ) function to assign the desired styles.
apple_style ="errorbars lt 4 lc 9"
set_option(with_= apple_style)
For myself I wrote a function "obtain_group_by_file_name(groupname)" that returns an output string containing the desired plot style:
apple_style ="errorbars lt 4 lc 9"
pear_style = "errorbars lt 6 lc 5"
def obtain_group_by_file(fruit,arg):
return = str( eval(fruit+"_style"))
In my loop I then generate a Gnuplot.File() for every file
[file1_apple.txt
file2_apple.txt
file3_apple.txt
file1_pear.txt
file2_pear.txt,...],
assign the desired style and append it to one list.
Eventually I plot only that one list:
plotlist = []
for cur_file in fileList:
group = files.split("_")[1]
f = Gnuplot.File(cur_file)
f.set_option(with_= obtain_group_by_file_name(group))
plotlist.append(f)
g.plot(*plotlist)
So in principle I did what you suggested: Making one list for plotting.
However thank you for your suggestion!
Best,
Bernhard
Am 22.12.2015 um 16:51 schrieb Michael Haggerty:
On 12/18/2015 04:13 PM, Bernhard Hopfenmüller wrote:
Dear Gnuplot-py-user List,
I have a problem I cannot quite solve, maybe somebody has a good idea?
So I have a script plotting all files of one folder in one graph.
I have the files already in a list "fileList":
Files belong to one of 2 groups, eg:
file1_apple.txt
file2_apple.txt
file3_apple.txt
file1_pear.txt
file2_pear.txt
.
.
.
I want now all files of one group to be plotted with the same symbol and
color. How do I do this?
It is sadly not working as I indicate it here
for cur_file in fileList:
group = files.split("_")[1]
if group== "apple":
f = Gnuplot.File(cur_file)
f.set_option(with_='points', linecolor = , linestyle = )
f.set_option(title=apple)
plotlist_apple.append(f)
if group == "pear":
f = Gnuplot.File(cur_file)
f.set_option(with_='points', linecolor =, linestyle = )
f.set_option(title=pear)
plotlist_pear.append(f)
#print plotlist
g.plot(*plotlist_pear,*plotlist_apple)
Also has anybody a hint how to plot that afterwards in one plot?
Your example isn't complete so it's hard to be sure. But at least part
of the problem is that the last line has a syntax error. It is not
possible to pass two splatted lists to a single function invocation in
this way. (Why not? I don't know. It seems like a reasonable thing to
do. But whatever.)
Instead, try
g.plot(*(plotlist_pear + plotlist_apple))
; i.e., combine the lists into a single list and then splat the big list
into the function call.
If that doesn't help, then please give us a more complete example,
including what you see and the error output if any.
Yours,
Michael
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzender des Aufsichtsrats: MinDir Dr. Karl Eugen Huthmacher
Geschaeftsfuehrung: Prof. Dr.-Ing. Wolfgang Marquardt (Vorsitzender),
Karsten Beneke (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
|