1
1
"""
2
2
3
- FUTURE IDEAS::
3
+ plot_vtk_matplotlib library for plotting VTK files in two dimensions
4
+ using Matplotlib
5
+
6
+ Authors: David Cortes, Hans Fangohr
7
+
8
+ License: BSD, stated in the Github repository:
9
+ https://github.com/fangohr/plot_vtk_matplotlib
10
+
11
+
12
+ FUTURE IDEAS::
4
13
5
14
A 3D plot is also possible to do, but the plt.quiver() function
6
15
is still under development, and handling thousands of vectors
22
31
23
32
import colorsys
24
33
25
- matplotlib .rcParams .update ({'font.size' : 22 }) # This should be equivalent
26
- # # in structure than before
34
+ # We can change Matplotlib parameters as
35
+ matplotlib .rcParams ['font.size' ] = 22
36
+ # Or as
27
37
matplotlib .rcParams .update ({'xtick.labelsize' : 16 })
28
38
matplotlib .rcParams .update ({'ytick.labelsize' : 16 })
29
39
@@ -101,7 +111,10 @@ def extract_data(self):
101
111
102
112
"""
103
113
104
- # Check the type of file to load it according ot it
114
+ # Check the type of file to load it according to its grid structure
115
+ # which was specified when calling the class These dictionary entries
116
+ # return the corresponding VTK Reader functions, so they can be easily
117
+ # called according to the class argument
105
118
reader_type = {
106
119
'XMLUnstructuredGrid' : lambda : vtk .vtkXMLUnstructuredGridReader (),
107
120
'XMLStructuredGrid' : lambda : vtk .vtkXMLStructuredGridReader (),
@@ -240,6 +253,7 @@ def plot_vtk(self,
240
253
colorbar_label = '' ,
241
254
quiver_type = 'raw_cmap' ,
242
255
quiver_color = 'k' ,
256
+ pivot = 'middle' ,
243
257
nx_q = 20 ,
244
258
ny_q = 20 ,
245
259
frame = True ,
@@ -356,6 +370,10 @@ def plot_vtk(self,
356
370
quiver_color :: Arrow color if one of the 'color' options was
357
371
specified in the quiver_type argument
358
372
373
+ pivot :: By default we make the arrows to be drawn at the
374
+ center of the grid nodes. This option is from
375
+ the matplotlib quiver function
376
+
359
377
nx_q, ny_q :: Resolution in the x and y directions for the
360
378
arrows in the quiver plot if one of the
361
379
interpolated quiver_type options are passed
@@ -644,6 +662,7 @@ def convert_to_rgb(a):
644
662
# component of m_component
645
663
quiv [v_component ],
646
664
cmap = quiver_map ,
665
+ pivot = pivot ,
647
666
** quiver_args
648
667
)
649
668
elif (quiver_type == 'interpolated_colour'
@@ -653,6 +672,7 @@ def convert_to_rgb(a):
653
672
quiv ['vx' ],
654
673
quiv ['vy' ],
655
674
color = quiver_color ,
675
+ pivot = pivot ,
656
676
** quiver_args
657
677
)
658
678
elif not quiver_type :
@@ -689,6 +709,7 @@ def plot_quiver(self,
689
709
interpolator = 'scipy' ,
690
710
quiver_type = 'raw_cmap' ,
691
711
quiver_color = 'k' ,
712
+ pivot = 'middle' ,
692
713
linewidth = 0.7 ,
693
714
x_min = - 10 , y_min = - 10 ,
694
715
x_max = 10 , y_max = 10 ,
@@ -757,6 +778,10 @@ def plot_quiver(self,
757
778
quiver_color :: Arrow color if one of the 'color' options was
758
779
specified in the quiver_type argument
759
780
781
+ pivot :: By default we make the arrows to be drawn at the
782
+ center of the grid nodes. This option is from
783
+ the matplotlib quiver function
784
+
760
785
linewidth :: Arrows line width
761
786
762
787
x_min, x_max :: Range of spatial x values to be used in the
@@ -868,6 +893,7 @@ def plot_quiver(self,
868
893
linewidth = linewidth ,
869
894
edgecolor = 'k' ,
870
895
facecolor = None ,
896
+ pivot = pivot ,
871
897
** kwargs
872
898
)
873
899
@@ -881,6 +907,7 @@ def plot_quiver(self,
881
907
alpha = alpha ,
882
908
linewidth = linewidth ,
883
909
color = quiver_color ,
910
+ pivot = pivot ,
884
911
** kwargs
885
912
)
886
913
0 commit comments