Open agladstein opened 6 years ago
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.
geom_raster
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()
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
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:
I tried it in Python:
but, got the following error: