@@ -205,11 +205,15 @@ subroutine initialize(me,grid,xlabel,ylabel,title,legend,use_numpy,figsize)
205
205
if (me% use_numpy) call me% add_str(' import numpy as np' )
206
206
call me% add_str(' ' )
207
207
208
- call me% add_str(' matplotlib.rcParams["font.size"] = 10.0' )
208
+ ! .... these also need to be optional user inputs ....
209
+
210
+ call me% add_str(' matplotlib.rcParams["font.size"] = 10' )
209
211
call me% add_str(' matplotlib.rcParams["font.family"] = "Serif"' )
210
- call me% add_str(' matplotlib.rcParams["axes.labelsize"] = 10.0' )
211
- call me% add_str(' matplotlib.rcParams["xtick.labelsize"] = 10.0' )
212
- call me% add_str(' matplotlib.rcParams["ytick.labelsize"] = 10.0' )
212
+ call me% add_str(' matplotlib.rcParams["axes.labelsize"] = 10' )
213
+ call me% add_str(' matplotlib.rcParams["xtick.labelsize"] = 10' )
214
+ call me% add_str(' matplotlib.rcParams["ytick.labelsize"] = 10' )
215
+ call me% add_str(' matplotlib.rcParams["legend.fontsize"] = 10' )
216
+
213
217
call me% add_str(' ' )
214
218
215
219
if (present (figsize)) then ! if specifying the figure size
@@ -261,28 +265,34 @@ subroutine add_plot(me,x,y,label,linestyle,markersize,linewidth)
261
265
character (len=* ),parameter :: xname = ' x' ! variable names for script
262
266
character (len=* ),parameter :: yname = ' y' !
263
267
264
- ! convert the arrays to strings:
265
- call vec_to_string(x,xstr,me% use_numpy)
266
- call vec_to_string(y,ystr,me% use_numpy)
268
+ if (allocated (me% str)) then
267
269
268
- ! get optional inputs (if not present, set default value) :
269
- call optional_int_to_string(markersize,imark, ' 3 ' )
270
- call optional_int_to_string(linewidth, iline, ' 3 ' )
270
+ ! convert the arrays to strings :
271
+ call vec_to_string(x,xstr,me % use_numpy )
272
+ call vec_to_string(y,ystr,me % use_numpy )
271
273
272
- ! write the arrays:
273
- call me% add_str(trim (xname)// ' = ' // xstr)
274
- call me% add_str(trim (yname)// ' = ' // ystr)
275
- call me% add_str(' ' )
274
+ ! get optional inputs (if not present, set default value):
275
+ call optional_int_to_string(markersize,imark,' 3' )
276
+ call optional_int_to_string(linewidth, iline,' 3' )
276
277
277
- ! write the plot statement:
278
- call me% add_str(' ax.plot(' // &
279
- trim (xname)// ' ,' // &
280
- trim (yname)// ' ,' // &
281
- ' "' // trim (linestyle)// ' ",' // &
282
- ' linewidth=' // trim (adjustl (iline))// ' ,' // &
283
- ' markersize=' // trim (adjustl (imark))// ' ,' // &
284
- ' label="' // trim (label)// ' ")' )
285
- call me% add_str(' ' )
278
+ ! write the arrays:
279
+ call me% add_str(trim (xname)// ' = ' // xstr)
280
+ call me% add_str(trim (yname)// ' = ' // ystr)
281
+ call me% add_str(' ' )
282
+
283
+ ! write the plot statement:
284
+ call me% add_str(' ax.plot(' // &
285
+ trim (xname)// ' ,' // &
286
+ trim (yname)// ' ,' // &
287
+ ' "' // trim (linestyle)// ' ",' // &
288
+ ' linewidth=' // trim (adjustl (iline))// ' ,' // &
289
+ ' markersize=' // trim (adjustl (imark))// ' ,' // &
290
+ ' label="' // trim (label)// ' ")' )
291
+ call me% add_str(' ' )
292
+
293
+ else
294
+ error stop ' Error in add_plot: pyplot class not properly initialized.'
295
+ end if
286
296
287
297
end subroutine add_plot
288
298
! *****************************************************************************************
@@ -317,31 +327,37 @@ subroutine add_bar(me,left,height,label,width,bottom,color)
317
327
character (len=* ),parameter :: wname = ' w' !
318
328
character (len=* ),parameter :: bname = ' b' !
319
329
320
- ! convert the arrays to strings:
321
- call vec_to_string(left,xstr, me% use_numpy)
322
- call vec_to_string(height,ystr,me% use_numpy)
323
- if (present (width)) call vec_to_string(width,wstr, me% use_numpy)
324
- if (present (bottom)) call vec_to_string(bottom,bstr,me% use_numpy)
325
-
326
- ! write the arrays:
327
- call me% add_str(trim (xname)// ' = ' // xstr)
328
- call me% add_str(trim (yname)// ' = ' // ystr)
329
- if (present (width)) call me% add_str(trim (wname)// ' = ' // wstr)
330
- if (present (bottom)) call me% add_str(trim (bname)// ' = ' // bstr)
331
- call me% add_str(' ' )
330
+ if (allocated (me% str)) then
332
331
333
- ! create the plot string:
334
- plt_str = ' ax.bar(' // &
335
- ' left=' // trim (xname)// ' ,' // &
336
- ' height=' // trim (yname)// ' ,'
337
- if (present (width)) plt_str= plt_str// ' width=' // trim (wname)// ' ,'
338
- if (present (bottom)) plt_str= plt_str// ' bottom=' // trim (bstr)// ' ,'
339
- if (present (color)) plt_str= plt_str// ' color="' // trim (color)// ' ",'
340
- plt_str= plt_str// ' label="' // trim (label)// ' ")'
341
-
342
- ! write the plot statement:
343
- call me% add_str(plt_str)
344
- call me% add_str(' ' )
332
+ ! convert the arrays to strings:
333
+ call vec_to_string(left,xstr, me% use_numpy)
334
+ call vec_to_string(height,ystr,me% use_numpy)
335
+ if (present (width)) call vec_to_string(width,wstr, me% use_numpy)
336
+ if (present (bottom)) call vec_to_string(bottom,bstr,me% use_numpy)
337
+
338
+ ! write the arrays:
339
+ call me% add_str(trim (xname)// ' = ' // xstr)
340
+ call me% add_str(trim (yname)// ' = ' // ystr)
341
+ if (present (width)) call me% add_str(trim (wname)// ' = ' // wstr)
342
+ if (present (bottom)) call me% add_str(trim (bname)// ' = ' // bstr)
343
+ call me% add_str(' ' )
344
+
345
+ ! create the plot string:
346
+ plt_str = ' ax.bar(' // &
347
+ ' left=' // trim (xname)// ' ,' // &
348
+ ' height=' // trim (yname)// ' ,'
349
+ if (present (width)) plt_str= plt_str// ' width=' // trim (wname)// ' ,'
350
+ if (present (bottom)) plt_str= plt_str// ' bottom=' // trim (bstr)// ' ,'
351
+ if (present (color)) plt_str= plt_str// ' color="' // trim (color)// ' ",'
352
+ plt_str= plt_str// ' label="' // trim (label)// ' ")'
353
+
354
+ ! write the plot statement:
355
+ call me% add_str(plt_str)
356
+ call me% add_str(' ' )
357
+
358
+ else
359
+ error stop ' Error in add_bar: pyplot class not properly initialized.'
360
+ end if
345
361
346
362
end subroutine add_bar
347
363
! *****************************************************************************************
@@ -509,15 +525,21 @@ subroutine savefig(me,figfile,pyfile)
509
525
character (len=* ),intent (in ) :: figfile ! file name for the figure
510
526
character (len=* ),intent (in ),optional :: pyfile ! name of the python script to generate
511
527
512
- ! finish up the string:
513
- if (me% show_legend) then
514
- call me% add_str(' ax.legend(loc="best")' )
515
- call me% add_str(' ' )
516
- end if
517
- call me% add_str(' plt.savefig("' // trim (figfile)// ' ")' )
528
+ if (allocated (me% str)) then
529
+
530
+ ! finish up the string:
531
+ if (me% show_legend) then
532
+ call me% add_str(' ax.legend(loc="best")' )
533
+ call me% add_str(' ' )
534
+ end if
535
+ call me% add_str(' plt.savefig("' // trim (figfile)// ' ")' )
518
536
519
- ! run it:
520
- call me% execute(pyfile)
537
+ ! run it:
538
+ call me% execute(pyfile)
539
+
540
+ else
541
+ error stop ' error in savefig: pyplot class not properly initialized.'
542
+ end if
521
543
522
544
end subroutine savefig
523
545
! *****************************************************************************************
0 commit comments