The full list of options can be found when typing help(ot) at the Python prompt. Plot(x,y,’-b’,linewidth=2) will plot a blue line ( b) with two two pixel thickness linewidth=2 which is twice as wide as the default. Plot(x,y,’-r’) will plot a line ( -) in red ( r) Plot(x,y,’og’) will plot circles ( o) in green ( g) (The syntax is very similar to MATLAB.) For example: Note further than you can chose different line styles, line thicknesses, symbols and colours for the data to be plotted. Xlabel(’.’) and ylabel(’.’) allow labelling the axes. Grid() This command will display a grid on the backdrop. Try help(pylab.legend) to learn more about the placement of the legend. Legend() This command will display a legend with the labels as defined in the plot command. Note that calling the plot command repeatedly, allows you to overlay a number of curves.Īxis() This fixes the displayed area to go from xmin=-2 to xmax=2 in x-direction, and from ymin=-1 to ymax=1 in y-direction The line label will be shown in the legend if the legend() command is used later. Plot(x,y1,label=’sin(x)’) The “label” keyword defines the name of this line. įigure(figsize=(5,5)) sets the figure size to 5inch by 5inch This chapter focusses on the Pylab interface.Īn excellent introduction and overview of the Matplotlib plotting interface is available in. If you use Matplotlib routinely to produce figures, you are well advised to learn about the object oriented matplotlib interface (instead of the pylab interface). Pylab is slightly more convenient to use for easy plots, and Matplotlib gives far more detailed control over how plots are created. Pylab is an interface to the same set of functions that imitates the (state-driven) Matlab plotting interface. Matplotlib as an object oriented plotting library. You can generate plots, histograms, power spectra, bar charts, errorcharts, scatterplots, etc, with just a few lines of code.įor more detailed information, check these linksĪ very nice introduction in the object oriented Matplotlib interface, and summary of all important ways of changing style, figure size, linewidth, etc. Matplotlib tries to make easy things easy and hard things possible. The Python library Matplotlib is a python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments. Matplotlib (Pylab) – plotting y=f(x), (and a bit more) ¶ Visual Python - which is a very handy tool to quickly generate animations of time dependent processes taking place in 3d space. Matplotlib/Pylab - which allows us to generate high quality graphs of the type y = f( x) (and a bit more) The purpose of scientific computation is insight not numbers: To understand the meaning of the (many) numbers we compute, we often need postprocessing, statistical analysis and graphical visualisation of our data.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |