-
Notifications
You must be signed in to change notification settings - Fork 26
add moran_facette
functionality and merge esda.moran
plots to moran_scatterplot
#27
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
Conversation
splot/_viz_value_by_alpha.py
Outdated
__author__ = ("Stefanie Lumnitz <stefanie.lumitz@gmail.com>") | ||
|
||
|
||
def value_by_alpha(x, alphay, gdf): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should get dropped
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I should have added value_by_alpha
functionality is dealt with separately in the next pr #28
splot/_viz_esda_mpl.py
Outdated
@@ -1062,3 +1160,113 @@ def moran_loc_bv_scatterplot(moran_loc_bv, p=None, | |||
ax.plot(lag, fit.predy, **fitline_kwds) | |||
ax.scatter(moran_loc_bv.zy, fit.predy, **scatter_kwds) | |||
return fig, ax | |||
|
|||
|
|||
def moran_facette(moran_matrix, figsize=(16,12), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
splot/_viz_esda_mpl.py
Outdated
sharey=True, sharex=True) | ||
fig.suptitle('Moran Facette') | ||
|
||
for row in range(nrows): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just as a suggestion: would it make sense to either use seaborn.FacetGrid
to make our facets more abstract, that way making them more re-usable across the library? You might have considered this already and it might make not sense but just checking here. Ideally, if we're gonna have facets in several places of splot
, the more we can reuse, the easier it'll be to maintain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seaboard.FacetGrid
takes as an input data : DataFrame Tidy (“long-form”) dataframe where each column is a variable and each row is an observation.
Since the Moran_BV_matrix
returns Moran_BV
objects I thought reusing the scatterplot, that plots Moran_BV
objects is the way to go. Otherwise we would need a Moran_Matrix
that returns spatially lagged values and values.
splot/_viz_esda_mpl.py
Outdated
|
||
Returns | ||
------- | ||
fig : Matplotlib Figure instance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it always return a fig
object? Even when ax
is not None
? I couldn't tell, but usually, if you pass and ax
I think usually you return only ax
(not completely sure though).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it always returns a fig
. If ax
is not None
, else: fig = ax.get_figure()
will create a fig
.
splot/_viz_value_by_alpha.py
Outdated
|
||
|
||
|
||
def value_by_alpha(x='attribute', y='alpha_attribute', c, data=geodataframe): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method name is picked in L.13, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I should have added value_by_alpha
functionality is dealt with separately in the next pr #28
splot/_viz_value_by_alpha.py
Outdated
fig, ax = geodataframe.plot(x, color=rgba) | ||
return fig, ax | ||
|
||
def make_RGBA_array_from_attribute(x): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unfinished, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I should have added value_by_alpha
functionality is dealt with separately in the next pr #28
splot/_viz_value_by_alpha.py
Outdated
|
||
def value_by_alpha(x='attribute', y='alpha_attribute', c, data=geodataframe): | ||
rgb = matplotlib.colors.to_rgba_array(c) | ||
alpha_channel = x/y.max() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! could we generalize it a bit? I'd like to be able to have:
- diverging scaling (extremes are opaque, middle is transparent, something like
(x-np.median(y)).abs() / np.abs(y).max()
- logarithmic scaling (including log divergent), which changes over the log of
y
(ory + y.min()
rather thany
directly, ify
has negative elements)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can try add more functionality to #28 :)
d80065a
to
d7ec801
Compare
Now, this is redundant, yes? |
Should the PR be closed or is it still in play? |
@jGaboardi Thank you this can be closed. |
moran_facet()
with documentation, tests and examplesmoran_scatterplot()
that can use allesda.moran
objects as inputwith documentation, tests and examples
This pull requests builds ontop of bug fixes in #25
and depends on the integration of
varnames
in esda pysal/esda#23