Showing posts with label Matplotlib. Show all posts
Showing posts with label Matplotlib. Show all posts

Draw multiple axhlines and axvlines in one function using Python & Matplotlib


The result is:

Draw multiple axhlines and axvlines in one function using Python and Matplotlib

This page shows how to draw multiple axhlines and axvlines in one function using python and matplotlib.

Convert color pdf to grayscale pdf using Python & Matplotlib via Ghostscript




This page shows how to convert color pdf figures generated by python and matplotlib into grayscale pdf via Ghostscript.

Plot 12-bit tiff image with log scale colorbar using python & matplotlib.pyplot


The result is:

Show 12-bit tiff image with log scale colorbar using python & matplotlib.pyplot

Some of the output data from measuring equipment have 12-bit unsigned int data. In some case, tiff format is used to ensure the convenience of the users. Reading the 12-bit tiff file and plotting the 12-bit tiff file is very easy. In addition, you can increase the visibility of the output figure by using log scale colormap when you plotting the tiff file. This page shows how to plot 12-bit tiff file in log scale using python and matplotlib.pyplot. 2D gaussian distribution is used as an example data.

Draw two axis to one colorbar using python and matplotlib.pyplot


The result is:

Draw two axis to one colorbar using python and matplotlib.pyplot

In my post in 14th, Oct. 2018, I showed how to draw second tick axis on the colorbar. The method of plotting is not so good, so I'd like to show an improved way to draw second tick axis on the colorbar. This page shows how to draw two axis to one colorbar using python and matplotlib.pyplot. By adapting twinx to the colorbar axis and by shifting the position of labels and ticks, you can draw an figure like the example on this page.

Combine three 2D colorap in one figure using Python and Matplotlib.pyplot


The result is:
If you want to plot three 2D colormaps on one figure, the only feasible way is combining these three colormaps to one image. This can be achieved by corresponding three values to three primary elements, i.e. red, green, blue. However, interpretation of the completed figure is quite complex, and easiness of understanding for readers would be decreased. In my opinion, this way for plotting should be avoided.

If you want to plot three 2D colormaps on one figure, the only feasible way is combining these three colormaps to one image. This can be achieved by corresponding three values to three primary elements, i.e. red, green, blue. However, interpretation of the completed figure is quite complex, and easiness of understanding for readers would be decreased. In my opinion, this way for plotting should be avoided.


Listing up sequential 2D colormap with one common colorbar using python and matplotlib.pyplot


The concept is:

Listing up sequential 2D colormap with one common colorbar using python and matplotlib.pyplot

When you want to show a 2D colormap in a sequence, the simplest way to do it is just listing up the output figure like the left side of the above image. However, common information, that is xticks and colorbars, should be omitted to show useful colormap as large as possible. This page shows how to align 2D colormaps without useless information. Three figures are drawn sequentially: 1. full image, 2. without colorbar, and 3. witiout colorbar and xticks. A standalone colorbar will be drawn, plotted and saved at the first iteration of the sequence. By properly selecting the output figure on your tools such as LaTex or Microsoft Office, you can obtain the figure like the right side of the above image.

Draw three colormap with two colorbar using python and matplotlib.pyplot


The result is:

Draw three colormap with two colorbar using python and matplotlib.pyplot

This page shows an example of how to arrange three colormap with two colorbar. One colorbar corresponds two colormaps, while the other corresponds to one colormap. Gridspec enables us to properly adjust these positions in the figure.

Extract data from tar.gz and expand on RAM using tarfile library, then plot using matplotlib


The concept of this article is:

Extract data from tar.gz and expand on RAM using tarfile library, then plot using matplotlib

This page shows an example of how to extract data from tar.gz file and expand not on HDD/SSD but on RAM, then plot some data using matplotlib.

Pcolor with cut data below lower limit using Python and matplotlib.pyplot


The result is:

This page shows how to generate pcolor graph with a data whose small values below minimum limit are cut using python and matplotlib.

This page shows how to generate pcolor graph with a data whose small values below minimum limit are cut using python and matplotlib.

Convert x value to symlog scale with zero shift using Python and matplotlib.pyplot


The result is:

Convert x value to symlog scale with zero shift using Python and matplotlib.pyplot

This code shows how to convert x value to symlog scale with zero shift using Python and matplotlib.pyplot

Two ways to align ylabels for two plots using Python and matplotlib.pyplot


The result is:

Two ways to align ylabels for two plots using Python and matplotlib.pyplot

This page shows two ways to align two ylabels for two subplots using Python and matplotlib.pyplot.

Generate figure with just only table using Python and matplotlib.pyplot


The result is:

Generate figure with just only table using Python and matplotlib.pyplot

This code shows how to generate a figure with just only a table using Python and matplotlib.pyplot

Generate network graph using Python and matplotlib.pyplot


The result is:


This page shows how to generate network graph using Python, matplotlib.pyplot and networkx.

Combine two figures with/without spines and ticks using Python and matplotlib.pyplot


The result is:

Combine two figures with/without spines and ticks using Python and matplotlib.pyplot

This code shows how to combine two figures with and without spines and ticks using Python and matplotlib.pyplot.

Remove ticks and spines (box around figure) using Python and maptlotlib.pyplot


The result is:

Remove ticks and spines (box around figure) using Python and maptlotlib.pyplot

This page shows how to remove ticks and spines (box around figure) using Python and matplotlib.pyplot.

Interactive plot using Bokeh - first step -


The result (static image) is:

Interactive plot using Bokeh - first step -

I firstly thought that Bokeh uses matplotlib. We generate figure using matplotlib then convert the figure to the Bokeh compatible. However, it seems Bokeh works stand alone without matplotlib (is it true?) Anyway, let's check whether Bokeh works in my environment or not.

Interactive time-scale stock price figure using Python, matplotlib.pyplot and mpld3


The result (static image) is:

Interactive time-scale stock price figure using Python, matplotlib.pyplot and mpld3

This page shows how to generate interactive figure using python, matplotlib.pyplot and mpld3. The stock information of the apple.inc is used as the example to plot.

Interactive figure with interactive legend using Python, matplotlib.pyplot and mpld3


The result (static image) is:

Interactive figure with interactive legend using Python, matplotlib.pyplot and mpld3

This page shows how to plot data in interactive figure using python, matplotlib.pyplot and mpld3. A interactive legend is added to the figure.

Animate 3D wireframe using animation.FuncAnimation in Python and maptlotlib.pyplot


The result is:

Animate 3D wireframe using animation.FuncAnimation in Python and maptlotlib.pyplot

This page shows how to animate 3D wireframe figure using animation.FuncAnimation in Python and matplotlib.pyplot.

Generate animation of 3D surface plot using plot_surface and animation.ArtistAnimation in Python and matplotlib.pyplot


The result is:

Generate animation of 3D surface plot using plot_surface and animation.ArtistAnimation in Python and matplotlib.pyplot

This page shows how to generate an animation of 3D surface plot using plot_surface and animation.ArtistAnimation in python and matplotlib.pyplot.