Plot black and white graphs suitable for papers with matplotlib or pylab

Academic societies require papers that are easy to read even in black and white. Although matplotlib and pylab are convenient, they are difficult to read if they are printed in black and white as they are because they output colorful graphs by default. So you need to do your best when plotting.

First, create a generator that creates the line format.

def monochrome_style_generator():
    linestyle = ['-', '--', '-.', ':']
    markerstyle = ['h' ,'2', 'v', '^', 's', '<', '>', '1', '3', '4', '8', 'p', '*', 'H', '+', ',', '.', 'x', 'o', 'D', 'd', '|', '_']
    line_idx = 0
    marker_idx = 0
    while True:
        yield 'k' + linestyle[line_idx] + markerstyle[marker_idx]
        line_idx = (line_idx + 1) % len(linestyle)
        marker_idx = (marker_idx + 1) % len(markerstyle)

What I defined like this

plot.py


import pylab

#Generator creation
gen = monochrome_style_generator()

xval = pylab.arange(100)*.01
for x in range(6):
  # gen.next()Generate line format with
  pylab.plot(xval, pylab.cos(x*pylab.pi*xval), gen.next())

pylab.savefig("result.png ", format = 'png')

By using it like this

result.png

You can output such a graph.

Recommended Posts

Plot black and white graphs suitable for papers with matplotlib or pylab
4 Techniques for Creating Diagrams for Papers and Presentation Materials with matplotlib
selenium: wait for element with AND / OR
Plot ROC Curve for Binary Classification with Matplotlib
(For those unfamiliar with Matplotlib) Tips for drawing graphs with Seaborn
2-axis plot with Matplotlib
3D plot with matplotlib
Dynamically generate graphs with matplotlib and embed in PDF with reporlab
Convert video to black and white with ffmpeg + python + opencv
Stackable bar plot with matplotlib
Animate multiple graphs with matplotlib