Matplotlib Styles for Scientific Plotting

There are at least two inspirations in writing this story. The first inspiration is coming from my participation in Summer School on Galaxies and Cosmology (SSGC 2020). It has three parts: Public Lecture, Lectures, and Workshops. One of the Workshops analyzed the weak gravitational lensing using Oguri et al. (2012) as the primary reference. Oguri-san gave the participants his code to analyze the lensing, including the Maptlotlib parameter settings. I won’t talk about the gravitational lensing, but how to generate a professional plot using Matplotlib, as shown in Oguri-san paper.

The other one comes from when I was reading the General Instructions to submit an article in Monthly Notices of the Royal Astronomical Society (MNRAS), one of the world’s leading primary research journals in astronomy and astrophysics. One of the parts in the instructions is how to embed figures in MNRAS. The authors are advised to ensure the color used in their figures are color-blind friendly. Here, I quote the instruction.

Where possible, please ensure that your figures are color-blind friendly. The use of red and green in the same figure is particularly problematic for some readers (General Instructions from MNRAS)

I was surprised by the instruction. I did not realize that we need to provide color-blind friendly in my figures/plots because I have no problem with color. After understanding it, I suggest you (all of the readers) perform color-blind friendly in your figures/plots. I will explain more about color blindness in the next part.

Main Goals

This story will guide you on how to:

  1. Customize Matplotlib parameters, using plotting style and rcParams
  2. Choose color-blind friendly

This story is significant for you who boost your data visualization skills because I will share how to generate professional plots based on the main goals mentioned before. So, let’s start it.

1.a Customize Matplotlib plotting style

Matplotlib provides users the style package to customize plotting style. If you did not change the style, you would get a default style, as shown in Figure 1.

python plotting with matplotlib scientific plots

Figure 1. Default plotting style in Matplotlib (Image by Author / Rizky MN).

By default, the background color is white, and the first color for the plot is blue. You can change it using style syntax, as shown in the following code.

import matplotlib as plt'fivethirtyeight') ## fivethirtyeight is name of style

#artificial-intelligence #machine-learning #data-science #programming #data-visualization

What is GEEK

Buddha Community

Matplotlib Styles for Scientific Plotting

Udit Vashisht


Matplotlib Tutorial - Bar Charts and reading in CSV Data - (Part 2)

Matplotlib Tutorial - Bar Charts and reading in CSV Data - (Part 2)
Part 2 of our Matplotlib Tutorial Videos Series is out…

In this video, we will learn creating bar charts in matplotlib. We will also learn to put bar charts side-by-side in matplotlib. Also, we will read in a csv file to create bar charts in Matplotlib .

#matplotlib #barcharts #pythonplotting #matplotlibtutorials #matplotlibvideos

#matplotlib #Matplotlib-tutorial-videos #matplotlib-plotting #matplotlib-bar-charts

The Matplotlib Line Plot that Crushes the Box Plot

Intuitively show statistics, error bars, or custom functions

The box plot is a quick and convenient way to get a feel for your data set — it can give you a snapshot of your range, mean, quartiles, and outliers. Sure, it’s not as descriptive as a histogram or kde for the distribution, but it’s fantastic for seeing how our distributions change over our variables.

While data scientists and most technical people are familiar and comfortable with box plots, they can be pretty foreign to people in non-engineering or statistics domains. And herein lies the problem: you need a way to show how your data trends and its distributions change in a format that anyone can understand.

I’m going to show you step-by-step how to make a line plot that conveys as much or as little information from the box plot that you’d like to share — means, medians, ranges, quartiles, standard deviation error bars, or any custom values.

#box-plot #pandas #line-plot #visualization #matplotlib

Hal  Sauer

Hal Sauer


Python Matplotlib Plotting BoxPlot

This is our seventh article in Python Matplotlib, in this article we are going to learn about Matplotlib Plotting BoxPlot. so in descriptive statistics, a box plot or boxplot is a method for graphically depicting groups of numerical data through their quartiles. Box plots may also have lines extending from the boxes indicating variability outside the upper and lower quartiles, hence the terms box-and-whisker plot and box-and-whisker diagram. also Boxplot allows you to compare distributions of values by conveniently showing the median, quartiles, maximum, and minimum of a set of values.

#matplotlib #python tutorials #matplotlib boxplot #python matplotlib

Lulu  Hegmann

Lulu Hegmann


Python Matplotlib Plotting Barchart - Code Loop

This is our fourth article in Python Matplotlib, in this article we are going to learn about Matplotlib Plotting Barchart.

#matplotlib #matplotlib barchart #python #python matplotlib

Kennith  Blick

Kennith Blick


Scatter Plots - Python Matplotlib Tutorial #3

In this Python tutorial, you will learn everything you need to know about scatter plots using Matplotlib library. Scatter plots are great in showing the relationship between variables in our dataset, eventually revealing a correlation.

This is a complete tutorial on scatter plots including Bubble plots and an additional variable mapped to the marker’s color (you will also learn how to add colorbar and choose the best colormap to your case). We will discuss how to change the marker of your scatter plot using two different methods: 1. Symbols from Matplotlib and 2. Symbols from Latex. As usual, I will share several tips and tricks to save your time when customizing your graph.

We will cover from the very basic to more advanced aspects in 15 minutes. I hope you enjoy this tutorial.

Playlist: Matplotlib Course | Video #3
Access the code here:

Learn how to use Jupyter Notebooks:

Additional Courses:
Beginner Python Tutorials:
Intermediate Python Tutorials:
NumPy Tutorials:

#matplotlib #python #python matplotlib tutorial #scatter plots