Skip to content

ax.step where parameter #359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
austin-hoover opened this issue May 15, 2022 · 3 comments
Closed

ax.step where parameter #359

austin-hoover opened this issue May 15, 2022 · 3 comments
Labels

Comments

@austin-hoover
Copy link

Description

In ax.step, the 'where' parameter doesn't do anything in proplot.

Steps to reproduce

import numpy as np
import proplot as pplt

x = np.linspace(-5.0, 5.0, 11)
y = np.exp(-0.5 * x**2)

fig, axes = pplt.subplots(nrows=3, figsize=(4.0, 3.0), spany=False)
for ax, where in zip(axes, ['pre', 'post', 'mid']):
    ax.step(x, y, where=where, color='black', alpha=0.2)
    ax.scatter(x, y, color='black', marker='.')
    ax.format(ylabel=where)

pplt

Expected behavior: The where parameter should shift the locations of the steps.

Actual behavior: The where parameter does not shift the locations of the steps.

Equivalent steps in matplotlib

import numpy as np
from matplotlib import pyplot as plt

x = np.linspace(-5.0, 5.0, 11)
y = np.exp(-0.5 * x**2)

fig, axes = plt.subplots(nrows=3, figsize=(4.0, 3.0), sharex=True)
for ax, where in zip(axes, ['pre', 'post', 'mid']):
    ax.step(x, y, where=where, color='black', alpha=0.2)
    ax.scatter(x, y, color='black', marker='.')
    ax.set_ylabel(where)

plt

Proplot version

matplotlib=3.4.3
proplot=0.9.5

@pguenth
Copy link

pguenth commented May 26, 2022

can confirm using proplot=0.9.5.post301 and matplotlib=3.5.2

@AWSisco
Copy link

AWSisco commented Jul 24, 2022

If you need an immediate solution to this using only Proplot, you can use the drawstyle argument with ax.plot instead to achieve the desired behavior.

import proplot as pplt
import numpy as np

x = np.linspace(-5.0, 5.0, 11)
y = np.exp(-0.5 * x**2)

fig, axes = pplt.subplots(nrows=3, figsize=(4.0, 3.0), spany=False)
for ax, drawstyle in zip(axes, ['steps', 'steps-post', 'steps-mid']):
    ax.plot(x, y, drawstyle=drawstyle, color='black', alpha=0.2)
    ax.scatter(x, y, color='black', marker='.')
    ax.format(ylabel=drawstyle, grid=False, ylocator=1)

drawstyle

proplot=0.9.5.post284
matplotlib=3.4.3

@lukelbd
Copy link
Collaborator

lukelbd commented Mar 29, 2023

This was a very simple fix (0e18bab). For some reason, a very long time ago, I added a "convenience" feature to step() converting where to this more complicated drawstyle='step-post' keyword arg... but I didn't realize step already had that conversion baked in / explicitly ignores drawstyle. So just removed the conversion. Result:

import numpy as np
import proplot as pplt

x = np.linspace(-5.0, 5.0, 11)
y = np.exp(-0.5 * x**2)

fig, axes = pplt.subplots(nrows=3, figsize=(4.0, 3.0), spany=False)
for ax, where in zip(axes, ['pre', 'post', 'mid']):
    ax.step(x, y, where=where, color='black', alpha=0.2)
    ax.scatter(x, y, color='black', marker='.')
    ax.format(ylabel=where)

iTerm2 9mY0iJ tmpqyd4v0eh

@lukelbd lukelbd added the bug label Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants