Peano
Loading...
Searching...
No Matches
MatplotlibPlotter.py
Go to the documentation of this file.
1# This file is part of the Peano project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3
4import matplotlib.pyplot as plt
5
6
7Symbols = [ "o", "s", "<", ">", "^", "v" ]
8
9
10def seismogram( dataset, column_number, labels, keys=None, marker_offset=0, total_marker_count=7, alter_default_settings=0.0):
11 """
12
13 Plot data for the particles over time. As we have a scatter plot,
14 the y-axis data is determined by column_number, i.e. that is the
15 data column used.
16
17 labels: [String]
18 Use None if you don't want a legend.
19
20 alter_default_settings: Double (0,1)
21 An double from [0,1[ to alter the default settings,
22 i.e. spacing and marker sizer. If you use this operation multiple
23 times in a row, I suggest you use increasing values, i.e. sequences
24 like 0.0,0.3,0.6.
25
26 """
27 if keys==None:
28 keys = list(dataset.extract_particle_keys())
29 print( "dataset hosts {} particles".format(len(keys)) )
30
31 symbol_counter = 0
32 for particle in keys:
33 print( "plot particle {}".format(particle) )
34 x_data, y_data = dataset.get_data(particle,column_number)
35 #
36 # First entry is offset, the second one the actual frequency
37 #
38 #keys.index(particle)
39 spacing = max(1,int(len(x_data)/total_marker_count))
40 offset = int( spacing/len(keys)*(keys.index(particle)+alter_default_settings) )
41 mark_every = (offset,spacing)
42 marker_size = 10 + int( 4.0 * 2.0 * (alter_default_settings-0.5) )
43
44 if len(x_data)!=len(y_data):
45 raise Exception( "x and y data size do not match")
46 if labels==None:
47 plt.plot( x_data, y_data, marker=Symbols[ symbol_counter%len(Symbols) ], markevery=mark_every, markersize=marker_size )
48 else:
49 plt.plot( x_data, y_data, marker=Symbols[ symbol_counter%len(Symbols) ], label=labels[symbol_counter], markevery=mark_every, markersize=marker_size )
50 symbol_counter += 1
51
52 pass