Skip to content

Default plotting parameters #43

@austin-hoover

Description

@austin-hoover

A few suggested changes to default plotting parameters that I make in the majority of my plotting scripts. Of course these are just my personal preferences.

Discrete colormaps

The "cmap.discrete" parameter is currently true by default. I like the convenience of calling ax.pcolormesh(image, discrete=True) and think discrete colormaps can be very useful, but usually I just want the regular behavior of pcolormesh, which is to use a continuous colormap.

Grid lines

The "axes.grid" parameter is currently true by default. I think grid lines can be useful but can also be unnecessary or distracting; for example when plotting an image. Maybe I'm alone here.

Figure padding

Ultraplot figures have significant padding when labels are added to the axes. I think the default should be to have less padding; for example when making a figure for a paper in two-column format. I'm not sure which parameter this corresponds to. I tried changing "subplots.outerpad", but that cuts off the top part of plot.

import numpy as np
import matplotlib.pyplot as plt

fig, ax = plt.subplots(figsize=(3.0, 3.0), constrained_layout=True)
values = np.arange(16).reshape(4, 4)
ax.pcolormesh(values)
ax.set_xlabel("xlabel")
ax.set_ylabel("ylabel")
plt.savefig("test1.png", dpi=200)


import ultraplot as uplt

uplt.rc["grid"] = False
uplt.rc["cmap.discrete"] = False
uplt.rc["cmap.sequential"] = "viridis"

fig, ax = uplt.subplots(figsize=(3.0, 3.0))
ax.pcolormesh(values)
ax.format(xlabel="xlabel", ylabel="ylabel")
plt.savefig("test2.png", dpi=200)


uplt.rc["subplots.outerpad"] = 0.0

fig, ax = uplt.subplots(figsize=(3.0, 3.0))
ax.pcolormesh(values)
ax.format(xlabel="xlabel", ylabel="ylabel")
plt.savefig("test3.png", dpi=200)

matplotlib==3.9.2
ultraplot==1.0.3.post14

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions