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
Subsetting data in plot #116
Comments
Currently it is not possible to specify data per geom. @glamp Currently the for geom in geoms:
_data = geom.data or self.data
for sub_layer in self._get_layers(_data):
[...]
|
Ok, it's (of course... :-/ ) not as easy: when you do that (and transform the data from the geom with the One way would be to refactor the |
This can be closed |
Awesome Jan, thank you for your contribution. I think I can update http://kldavenport.com/mahalanobis-distance-and-outliers/ now :) |
Let's see if it works for you :-) |
downloaded you ipynb and run it here: it works :-) |
Just for the reference, here are the changes I had to do to the : # needed because in latest pandas, the series are not anymore numpy arrays...
# see https://github.com/pydata/pandas/issues/5698
xydata = DF_diff_xy.values
xycols = DF_diff_xy.columns
--
%%R -i xydata,xycols # list object to be transferred to python here
install.packages("ggplot2") # Had to add this for some reason, shouldn't be necessary
library(ggplot2)
df = data.frame(xydata)
names(df) <- c(xycols)
plot = ggplot(df, aes(x = X, y = Y)) +
geom_point(alpha = .8, color = 'dodgerblue',size = 5) +
geom_point(data=subset(df, Y >= 6.7 | X >= 4), color = 'red',size = 6) +
theme(axis.text.x = element_text(size= rel(1.5),angle=90, hjust=1)) +
ggtitle('Distance Pairs with outliers highlighted in red')
print(plot)
--
from ggplot import *
ggplot(DF_diff_xy, aes(x = 'X', y ='Y')) + \
geom_point(alpha=1, size=100, color='dodgerblue') + \
geom_point(data = DF_diff_xy[(DF_diff_xy.Y >= 6.7) | (DF_diff_xy.X >= 4)],alpha=1, size = 100, color='red') |
Just tried it, works perfectly! Will start updating my blog post now :) |
In R I can plot additional points based on some other criteria using the R subset command as follows:
In Python my thinking was I could specify a row slice of a dataframe for additional highlight as so:
This didn't work however, any ideas?
Thanks,
Kevin Davenport
http://kldavenport.com
The text was updated successfully, but these errors were encountered: