Skip to content

How to change the dataframe used for plotting #623

Closed Answered by has2k1
tabedzki asked this question in Q&A
Discussion options

You must be logged in to vote

Create a base plot without data and hide the geoms in a function that takes data and returns a list of layers that plot that data.

def layers(data):
    return [geom_point(data), geom_line(data)]

base = ( ggplot( 
    mapping= aes(x="Ns", y="chiNs_corrected", color="factor(Nb)"),) 
    + facet_grid("sides ~ backbone", labeller="label_both") \
    + theme(figure_size=(5, 4))
)

base + layers(data)
base + aes(y='d') + layers(data)
base + aes(y='e') + layers(data.query('a > b'))

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tabedzki
Comment options

Answer selected by tabedzki
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants