-
Notifications
You must be signed in to change notification settings - Fork 53
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
how to draw geom_bands or geom_text on bar graph with discrete bars #1279
Comments
Hi, thanks, happy New Year to you too! |
In my opinion, an easier way would be to keep the x-axis discrete and add all annotating bands and texts with their attributes set via parameters (as opposed to using data mapping via Here's how it can work:
|
Numeric coordinates of the tick-marks will be the same and you will use decimal numbers for positioning anywhere between or beyond the tick-marks. So, basically will be no difference.
Right, all is written in Kotlin then compiled to JS. |
Happy New Year,
An easy one for the start of the year.
I'm trying to draw a geom_bands and text across discrete bars.
In the graph below I want to draw three vertical bands of different colours that highlight the bins belonging
to the same company - Subaru: ['Outback', 'Impreza', 'BRZ'], Volkswagen: ['Jetta', 'Passat'] and
AMC ['Matador', 'Rambler', 'Pacer'] and also label each band.
I'm not sure how to obtain the position and bin width of the discrete bins so to use as numerical values for geom_band(xmin, xmax).
Same issue for geom_text.
`
import numpy as np
import pandas as pd
from lets_plot import *
LetsPlot.setup_html()
np.random.seed(69)
cars = pd.DataFrame({
'Models': ['Outback', 'Impresa', 'BRZ', 'Jetta', 'Passat', 'Matador', 'Rambler', 'Pacer'],
'Val': np.random.uniform(0,100, size=8)
})
p3 = (ggplot(data=cars, mapping=aes(x='Models', weight='Val')) + geom_bar())
`
Thanks!
The text was updated successfully, but these errors were encountered: