software:matplotlib:matplotlib

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
software:matplotlib:matplotlib [2018-04-26 11:54] – [Matplotlib] sraskarsoftware:matplotlib:matplotlib [2024-02-20 10:30] (current) – [Matplotlib] anita
Line 5: Line 5:
 Matplotlib, pylab and pyplot are all related.  Matplotlib is the whole package; pylab is a module in matplotlib that gets installed alongside [[http://matplotlib.org/api/matplotlib_configuration_api.html#module-matplotlib|matplotlib]]; and [[http://matplotlib.org/api/pyplot_api.html#module-matplotlib.pyplot|matplotlib.pyplot]] is a module in matplotlib. There is a [[http://matplotlib.org/users/pyplot_tutorial.html|pyplot tutorial]] and numerous other sites that use matplotlib for their plot examples such as [[http://www.scipy.org/Cookbook/Matplotlib/|SciPy Cookbook for Matplotlib]]. Matplotlib, pylab and pyplot are all related.  Matplotlib is the whole package; pylab is a module in matplotlib that gets installed alongside [[http://matplotlib.org/api/matplotlib_configuration_api.html#module-matplotlib|matplotlib]]; and [[http://matplotlib.org/api/pyplot_api.html#module-matplotlib.pyplot|matplotlib.pyplot]] is a module in matplotlib. There is a [[http://matplotlib.org/users/pyplot_tutorial.html|pyplot tutorial]] and numerous other sites that use matplotlib for their plot examples such as [[http://www.scipy.org/Cookbook/Matplotlib/|SciPy Cookbook for Matplotlib]].
  
 +<note tip>These directions are geared towards setting up and running Matplotlib on Caviness. However these directions can easily be used on DARWIN, although references to directory paths and software versions may be different.</note>
 ===== Interactive job ===== ===== Interactive job =====
  
-All interactive jobs should be run on a compute node by setting your ''workgroup'' and using ''qlogin''. You need to be running X-Windows and you should make sure you are in the directory where your input and output files will be stored.  In the example below, we are using the ''traine'' account in workgroup ''it-css'' to create the ''plot123.png'' file using Python packages Scipy and Matplotlib.+All interactive jobs should be run on a compute node by setting your ''workgroup'' and using ''salloc'' and the proper X11 settings since you need to be running X-Windows to produce graphics. Also make sure you are in the directory where your input and output files will be stored.  In the example below, we are using the ''traine'' account in workgroup ''it-css'' to create the ''plot123.png'' file using Python packages Matplotlib and using the Intel version of Python since it comes with the packages we need without having to create our own Python virtual environment.
  
 <code bash> <code bash>
-[(it_css:traine)@mills traine]$ qlogin +[traine@login01.caviness ~]$ workgroup -g it_css 
-Your job 136505 ("QLOGIN") has been submitted +[(it_css:traine)@login01.caviness ~]$ salloc --partition=it_css --x11 -N1 -n1 
-waiting for interactive job to be scheduled ... +salloc: Granted job allocation 26918710 
-Your interactive job 136505 has been successfully scheduled. +salloc: Waiting for resource configuration 
-Establishing /opt/shared/GridEngine/local/qlogin_ssh session to host n016 ... +salloc: Nodes r00n45 are ready for job 
-Last loginMon Dec 10 15:05:04 2012 from mills.mills.hpc.udel.edu +[(it_css:traine)@r00n45 ~]$ vpkg_require intel-python 
-[anita@n016 traine]$ vpkg_require scipy matplotlib +Adding package `intel-python/2022u1:python3` to your environment 
-Adding dependency `python/2.7.2` to your environment +[(it_css:traine)@r00n45 ~]$ python 
-Adding dependency `python-nose/1.1.2-2.7` to your environment +Python 3.9.10 (mainMar  2 202212:02:00
-Adding dependency `mkl/10.3.8-64bit` to your environment +[GCC 9.3.0:: Intel Corporation on linux
-Adding dependency `numpy/1.6.1-2.7` to your environment +
-Adding package `scipy/0.10.0-2.7` to your environment +
-Adding dependency `x11/RHEL6.1` to your environment +
-Adding dependency `pycairo/1.8.6-2.7.2` to your environment +
-Adding dependency `pygtk/2.16.0-2.7.2` to your environment +
-Adding package `matplotlib/1.1.0-2.7.2` to your environment +
-[anita@n016 traine]$ python +
-Python 2.7.(defaultDec 27 201115:05:10+
-[GCC 4.4.5 20110214 (Red Hat 4.4.5-6)] on linux2+
 Type "help", "copyright", "credits" or "license" for more information. Type "help", "copyright", "credits" or "license" for more information.
->>> import pygtk+Intel(R) Distribution for Python is brought to you by Intel Corporation. 
 +Please check out: https://software.intel.com/en-us/python-distribution 
 +>>> import scipy
 >>> import matplotlib >>> import matplotlib
 >>> from pylab import * >>> from pylab import *
 >>> plot([1,2,3]) >>> plot([1,2,3])
-[<matplotlib.lines.Line2D object at 0x242ce10>]+[<matplotlib.lines.Line2D object at 0x2b9e83d2bee0>]
 >>> show() >>> show()
 >>> quit() >>> quit()
-[traine@n016 traine]$ ls *.png+[(it_css:traine)@r00n45 ~]$ ls *.png
 plot123.png plot123.png
 </code> </code>
Line 49: Line 43:
  
 <code - plot-ex.py> <code - plot-ex.py>
 +# Python program to generate plots in batch
 +
 import matplotlib import matplotlib
 matplotlib.use("AGG") matplotlib.use("AGG")
Line 64: Line 60:
 </code> </code>
    
-Now we can use this python plot example file and run it using a basic serial job script. +Now we can use this Python plot example file and run it using a basic serial job script.  Copy the job script template from ''/opt/shared/templates/slurm/generic/serial.qs'' and call it ''serial-plot.qs''. Modify ''serial-plot.qs'' to set the correct partition, add the correct packages with VALET ''vpkg_require intel-python'' and replace ''srun date'' with ''python plot-ex.py''. Remember ''_workgroup_'' can be used for the partition because in order to submit jobs, the workgroup must be set using the ''workgroup'' command, so whatever workgroup has been set will be substituted in for ''_workgroup'' This allows our job scripts to be more flexible when you have more than one workgroup on the cluster.
    
 <code - serial-plot.qs> <code - serial-plot.qs>
 +#
 +#        To run with priority-access to resources owned by your workgroup,
 +#        use the "_workgroup_" partition:
 +#
 +#SBATCH --partition=_workgroup_
  
-Setup the environment; add vpkg_require commands after this +# 
-# line: +# If you have VALET packages to load into the job environment, 
-vpkg_require scipy matplotlib +uncomment and edit the following line: 
- +
-Now append all of your shell commands necessary to run your program +#vpkg_require intel/2019 
-after this line:+vpkg_require intel-python
  
 +#
 +# [EDIT] Add your script statements hereafter, or execute a script or program
 +#        using the srun command.
 +#
 +#srun date
 python plot-ex.py python plot-ex.py
 +
 </code> </code>
    
Line 81: Line 88:
  
 <code bash> <code bash>
-qsub serial-plot.qs+sbatch serial-plot.qs
 </code> </code>
    
Line 87: Line 94:
  
 <code bash> <code bash>
-[(it_css:traine)@mills matplotlib]$ ls +[(it_css:traine)@login01.caviness matplotlib]$ ls 
-plot-cs.png  plot-ex.py  serial-plot.qs  serial.qs.o138451+plot-cs.png  plot-ex.py  serial-plot.qs  slurm-26918733.out
 </code> </code>
  
 ==== View plots with Imagemagick ==== ==== View plots with Imagemagick ====
  
-If you want to review the plots created, then you can use Imagemagick on the compute nodes via qlogin as long as you are running X-Windows. For example, using account ''traine'' and workgroup ''it_css'', we display the ''plot-cs.png'' plot file.+If you want to review the plots created, then you can use Imagemagick on the compute nodes via ''salloc'' with the proper X11 options and you are running X-Windows. For example, using account ''traine'' and workgroup ''it_css'', we display the ''plot-cs.png'' plot file. 
    
 <code bash> <code bash>
-[(it_css:traine)@mills matplotlib]$ qlogin +[(it_css:traine)@login01.caviness matplotlib]$ salloc --partition=it_css --x11 -N1 -n1 
-Your job 150600 ("QLOGIN") has been submitted +salloc: Granted job allocation 26918735 
-waiting for interactive job to be scheduled ... +salloc: Waiting for resource configuration 
-Your interactive job 150600 has been successfully scheduled. +salloc: Nodes r04n16 are ready for job 
-Establishing /opt/shared/GridEngine/local/qlogin_ssh session to host n016 ... +[(it_css:traine)@r04n16 matplotlib$ vpkg_require imagemagick 
-Last loginWed Dec 19 15:24:03 2012 from mills.mills.hpc.udel.edu +Adding dependency `fftw/3.3.8` to your environment 
-[traine@n016 matplotlib]$ vpkg_require imagemagick +Adding dependency `ghostscript/9.23` to your environment 
-Adding dependency `x11/RHEL6.1` to your environment +Adding package `imagemagick/7.0.8-3` to your environment 
-Adding dependency `fftw/3.3-gcc-openmp` to your environment +[(it_css:traine)@r04n16 matplotlib]$ display plot-cs.png
-Adding dependency `open64/4.5` to your environment +
-Adding dependency `ffmpeg/20120319-open64` to your environment +
-Adding package `imagemagick/6.7.6-3` to your environment +
-[traine@n016 matplotlib]$ display plot-cs.png+
 </code> </code>
  
Line 141: Line 144:
 </code> </code>
  
-Using a basic serial job script like ''serial-plot-latex.qs'' below which loads the appropriate packages, then use ''qsub serial-plot-latex.qs'' will create the plot file ''latex_demo.png'' in the current working directory where you submitted the job.+Using a basic serial job script like ''serial-plot.qs'' copy it and make changes below to set the partition, include the appropriate VALET packages and the command to run Python, then use ''sbatch serial-plot-latex.qs'' to submit the job. This job will create the plot file ''latex_demo.png'' in the current working directory where you submitted the job.
  
 <code - serial-plot-latex.qs> <code - serial-plot-latex.qs>
-Setup the environment; add vpkg_require commands after this +# 
-# line: +#        To run with priority-access to resources owned by your workgroup, 
-vpkg_require numpy matplotlib +#        use the "_workgroup_" partition: 
-vpkg_require texlive+
 +#SBATCH --partition=_workgroup_ 
 + 
 +
 +# If you have VALET packages to load into the job environment, 
 +uncomment and edit the following line: 
 +
 +#vpkg_require intel/2019 
 +vpkg_require intel-python texlive
  
-Now append all of your shell commands necessary to run your program +# 
-after this line:+# [EDIT] Add your script statements hereafter, or execute a script or program 
 +       using the srun command. 
 +
 +#srun date
  
 python latex_demo.py python latex_demo.py
 </code> </code>
  • software/matplotlib/matplotlib.1524758040.txt.gz
  • Last modified: 2018-04-26 11:54
  • by sraskar