Skip to content
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

geom_raster #635

Open
agladstein opened this issue Feb 7, 2018 · 0 comments
Open

geom_raster #635

agladstein opened this issue Feb 7, 2018 · 0 comments

Comments

@agladstein
Copy link

Hi,

Is there a geom_raster equivalent in the the Python ggplot? I have a plot in R that I'd like to incorporate into a Python script, but I can't find a way to do it.

Here is my R ggplot code and plot:

ggplot(joint_NEA_NWA, aes(x = Log10_NWA, y = Log10_NEA)) + 
  geom_raster(aes(fill = density)) +
  geom_abline(intercept = 0) +
  geom_point(x = 3.91105, y = 4.96332, shape = 8) + 
  scale_fill_viridis() +
  labs(y = "Log10_NEA", x = "Log10_NWA") +
  theme(legend.title=element_blank()) +
  theme_bw()

joint_density_plot_10pls_1000ret

I tried it in Python:

def plot_joint_gg(joint_NEA_NWA_df):

    plot = ggplot(aes(x='Log10_NWA', y='Log10_NEA'), data = joint_NEA_NWA_df) + \
           geom_abline(intercept=0) + \
           geom_raster(aes(fill=density))

    return plot

join_plot = plot_joint_gg(joint_NEA_NWA_df)
print(join_plot)

but, got the following error:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-28-8c23577b6a81> in <module>()
     10     return plot
     11 
---> 12 join_plot = plot_joint_gg(joint_NEA_NWA_df)
     13 print(join_plot)

<ipython-input-28-8c23577b6a81> in plot_joint_gg(joint_NEA_NWA_df)
      1 def plot_joint_gg(joint_NEA_NWA_df):
      2 
----> 3     plot = ggplot(aes(x='Log10_NWA', y='Log10_NEA'), data = joint_NEA_NWA_df) +            geom_abline(intercept=0) +            geom_raster(aes(fill=density))
      4 #            geom_point(x=4.12121, y=6.4, shape=8) + \
      5 #            scale_fill_viridis() + \

NameError: name 'geom_raster' is not defined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant