#Python how to install matplotlib how to#
Here are arguments of the ScaleBar class constructor and examples how to use them. imshow ( im, cmap = "gray" ) # Create scale bar scalebar = ScaleBar ( 0.08, "cm", length_fraction = 0.25 ) ax. reshape (( 256, 256 )) # Create subplot fig, ax = plt.
![python how to install matplotlib python how to install matplotlib](https://blog.finxter.com/wp-content/uploads/2021/09/image-40-1024x630.png)
get_sample_data ( "" ) as dfile : im = np. import numpy as np import matplotlib.pyplot as plt import matplotlib.cbook as cbook from matplotlib_scalebar.scalebar import ScaleBar # Load image with cbook. In this example, we load a sample image from the matplotlib library, create a subplot, plot image, create scale bar and add scale bar as an "artist" of the subplot. See examples below for other system of units. The constructor arguments dx and units specify the pixel dimension.įor example ScaleBar(0.2, 'um') indicates that each pixel is equal to 0.2 micrometer.īy default, the scale bar uses SI units of length (e.g. There are many ways to customize the scale bar.Įxamples and explanations of the arguments of the ScaleBar class are given below, but here is a quick start guide.
![python how to install matplotlib python how to install matplotlib](https://matplotlib.org/1.3.1/mpl_examples/color/colormaps_reference_02.hires.png)
![python how to install matplotlib python how to install matplotlib](https://deparkes.co.uk/wp-content/uploads/2012/06/2075029993_9875c4d3fe_o.png)
InstallationĮasiest way to install using pip: pip install matplotlib-scalebarįor development installation from the git repository: git clone install -e matplotlib-scalebar The artist supports customization either directly from the ScaleBar object or from the matplotlibrc. It is particularly useful when displaying calibrated images plotted using Provides a new artist for matplotlib to display a scale bar, aka micron bar.