Skip to content
This repository has been archived by the owner on Jun 5, 2020. It is now read-only.

How to add vertical and horizontal lines to figures? #21

Open
BlackArbsCEO opened this issue Feb 14, 2018 · 6 comments
Open

How to add vertical and horizontal lines to figures? #21

BlackArbsCEO opened this issue Feb 14, 2018 · 6 comments

Comments

@BlackArbsCEO
Copy link

Please advise.

@jakevdp
Copy link
Member

jakevdp commented Feb 14, 2018

In master, you can do this by layering, but that's not very convenient at the moment. It would be something like:

ax = data.vgplot(x='x', y='y')

# draw a line at y = 5
hline = pd.DataFrame({'x': data.x,
                      'y': 5 * np.ones_like(data.x)})
hline.vgplot(x='x', y='y', ax=ax)

(Note that this is not yet available in the version that's installable from pip.)

I've been thinking about this use case, and whether it would make sense to add ax.hlines([n1, n2]) and ax.vlines([n1, n2]) methods a la matplotlib for this use case.

@BlackArbsCEO
Copy link
Author

@jakevdp thanks.

I think it would be helpful to add the hlines and vlines feature. My top use cases are to emphasize the zero line and to highlight important values when plotting distributions. I can also imagine wanting to shade a range between vlines, for example shading recessions when plotting economic time series.

@uribe-convers
Copy link

@jakevdp I'm loving altair so far but I agree that adding hlines and vlines would make it even better! Hopefully something easy to use like ggplot's + geom_vline(xintercept=2).

I tried following the advice given on altair's issue #1124 but it didn't really work that well.

Keep up the good work and thank you for this awesome library.

@jakevdp
Copy link
Member

jakevdp commented Sep 11, 2018

Are you working in altair or in pdvega?

@uribe-convers
Copy link

In Altair, just noticed that I posted on the pdvega repo, sorry about that. I was looking everywhere for ways to draw the vertical line and didn’t realize. I can post this to Altair if you prefer.

@jakevdp
Copy link
Member

jakevdp commented Sep 11, 2018

Maybe you could comment on vega/altair#1124 with the problem you're having with the solution there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants