PYTHON   4

setplot.py

Guest on 16th May 2021 08:43:08 PM

  1.  
  2. """
  3. Set up the plot figures, axes, and items to be done for each frame.
  4.  
  5. This module is imported by the plotting routines and then the
  6. function setplot is called to set the plot parameters.
  7.    
  8. """
  9.  
  10. import numpy as np
  11.  
  12. #--------------------------
  13. def setplot(plotdata):
  14. #--------------------------
  15.    
  16.     """
  17.    Specify what is to be plotted at each frame.
  18.    Input:  plotdata, an instance of pyclaw.plotters.data.ClawPlotData.
  19.    Output: a modified version of plotdata.
  20.    
  21.    """
  22.  
  23.  
  24.     from pyclaw.plotters import colormaps
  25.  
  26.     plotdata.clearfigures()  # clear any old figures,axes,items data
  27.    
  28.  
  29.     # Figure for pcolor
  30.     plotfigure = plotdata.new_plotfigure(name='q[0]', figno=0)
  31.  
  32.     # Set up for axes in this figure:
  33.     plotaxes = plotfigure.new_plotaxes()
  34.     plotaxes.xlimits = 'auto'
  35.     plotaxes.ylimits = 'auto'
  36.     plotaxes.title = 'q[0]'
  37.     plotaxes.afteraxes = "pylab.axis('scaled')"
  38.  
  39.     # Set up for item on these axes:
  40.     plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor')
  41.     plotitem.plot_var = 0
  42.     plotitem.pcolor_cmap = colormaps.yellow_red_blue
  43.     plotitem.add_colorbar = True
  44.     plotitem.show = True       # show on plot?
  45.    
  46.  
  47.     # Figure for contour
  48.     plotfigure = plotdata.new_plotfigure(name='contour', figno=1)
  49.  
  50.     # Set up for axes in this figure:
  51.     plotaxes = plotfigure.new_plotaxes()
  52.     plotaxes.xlimits = 'auto'
  53.     plotaxes.ylimits = 'auto'
  54.     plotaxes.title = 'q[0]'
  55.     plotaxes.afteraxes = "pylab.axis('scaled')"
  56.  
  57.     # Set up for item on these axes:
  58.     plotitem = plotaxes.new_plotitem(plot_type='2d_contour')
  59.     plotitem.plot_var = 0
  60.     plotitem.contour_levels = np.linspace(0.2,0.9,8)
  61.     plotitem.contour_colors = 'k'
  62.     plotitem.show = True       # show on plot?
  63.    
  64.  
  65.     # Parameters used only when creating html and/or latex hardcopy
  66.     # e.g., via pyclaw.plotters.frametools.printframes:
  67.  
  68.     plotdata.printfigs = True                # print figures
  69.     plotdata.print_format = 'png'            # file format
  70.     plotdata.print_framenos = 'all'          # list of frames to print
  71.     plotdata.print_fignos = 'all'            # list of figures to print
  72.     plotdata.html = True                     # create html files of plots?
  73.     plotdata.html_homelink = '../README.html'   # pointer for top of index
  74.     plotdata.latex = True                    # create latex file of plots?
  75.     plotdata.latex_figsperline = 2           # layout of plots
  76.     plotdata.latex_framesperline = 1         # layout of plots
  77.     plotdata.latex_makepdf = False           # also run pdflatex?
  78.  
  79.     return plotdata

Raw Paste


Login or Register to edit or fork this paste. It's free.