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

sugguestion about plot_local_autocorrelation #60

Open
stevenlis opened this issue May 15, 2019 · 5 comments
Open

sugguestion about plot_local_autocorrelation #60

stevenlis opened this issue May 15, 2019 · 5 comments

Comments

@stevenlis
Copy link

pysal: 2.0.0

It's my first time to plot with splot and I think maybe I can offer some suggestions as I've seen many idea collection issues.

download

  1. plot_local_autocorrelation doesn't seem supporting ax, so it might be a good idea to add a arg to control the layout e.g., 3 by 1 or 1 by 3. (the function does return one Fig and three Axes. Is there any way to manipulate them just as any Axes? Maybe I missed something.)

  2. adding a map_kwds or something to control the maps.

  3. Since the slope of the line in the Moran scatterplot represents the global Moran's I, it might be a good idea to set xlim equal to ylim, so that a line flatter than 45 degrees means the Moran's I is less than 0.5. Since different xlim and ylim will visually affect the slope of the line, it may cause problem sometimes especially when we compare two plots. (Btw, Geoda doesn't plot outliers in the Moran scatterplot, so I'm curious of how outliers are handled in splot)

  4. display global Moran's I and its p-value. I think most of the time, we need it as well.

  5. The current API seems to use Local Moran object as input. Every time I change the variable I want to plot, then I have to calculate it again, so I think it might be easier to actually just use the columns as input.

  6. I'm actually curious if it is possible to simplify the API of splot to just have one function and then use args to choose which plot to display like lisa_cluster=False.

Btw, thanks for this amazing work and user-friendly package that makes plotting easy with Python.💕💕💕

@slumnitz
Copy link
Member

Hello @StevenLi-DS,

thank you for your suggestions and ideas! We are always grateful for feedback and happy to accommodate users as much as possible! In fact, we are currently working to implement 3. in #51 . Your point 1. and 4. will most likely be part of the next release as well, these are great additions!

As to your first point, I am not sure if I understood you correctly, you can manipulate single Axes through defining fig, axs = plot_local_autocorrelation() and e.g. calling axs[0].set_axis_off(). I think adding a layout option is a great idea though, since Matplotlib currently does not support rearranging axes once a figure is drawn. Alternatively, you could directly use the moran_scatterplot(ax=axs[0,0]) lisa_cluster(ax=axs[0,1]) andgdp.plot(ax=axs[0,2]) and arrange them in a new figure in a format you would like.

What exactly would you like to have more control over in 2. with a map_kwds?

Thanks again for the suggestions! We are happy to hear splot is making your life easier!

@stevenlis
Copy link
Author

Hi, @slumnitz. Thanks for your reply.

I actually tried fig, axs = plot_local_autocorrelation() before posting and it seems like I missed something and I just tried it again and indeed it's working as expected.

What exactly would you like to have more control over in 2. with a map_kwds?

The doc says the map plots use .plot() in geopandas so I wish I could pass some kwds to control the map. For example, for the above plot, I may wanna set the edge color to grey or something. I actually eventually end up using moran_scatterplot() and lisa_cluster() as receiving they would give me more controls.😊

@qizidog
Copy link

qizidog commented Dec 28, 2021

Some more feedback, I'm trying to explore autocorrelation of some linestring geometry through plot_local_autocorrelation() and lisa_cluster() method, but a figure without anything except a legend is returned. Everything works as expected after changing the linestring geometry to it's centroid point geometry. I guess that the linestring geometry is not supported perfectly enough?

The version of splot is 1.1.4

@qizidog
Copy link

qizidog commented Dec 28, 2021

Some more feedback, I'm trying to explore autocorrelation of some linestring geometry through plot_local_autocorrelation() and lisa_cluster() method, but a figure without anything except a legend is returned. Everything works as expected after changing the linestring geometry to it's centroid point geometry. I guess that the linestring geometry is not supported perfectly enough?

The version of splot is 1.1.4

I checked it again and found it is caused by the fixed parameter values of linewidth=0.1 and edgecolor='white' of the plot() function in lisa_cluster(). As a result, all geometry of linestring will be invisable with a white backgroud at the same time.

Maybe it is better to do some adjust in source code with linestring geometry detected :)

As it's not convenient to set additional config I have to modify the source code (just remove the two fixed parameter values) as follow:

# original source code
# gdf.assign(cl=labels).plot(column='cl', categorical=True,
#                            k=2, cmap=hmap, linewidth=0.1, ax=ax,
#                            edgecolor='white', legend=legend,
#                            legend_kwds=legend_kwds, **kwargs)
gdf.assign(cl=labels).plot(column='cl', categorical=True,
                           k=2, cmap=hmap, ax=ax,
                           legend=legend,
                           legend_kwds=legend_kwds, **kwargs)

@jGaboardi
Copy link
Member

@qizidog This has been fixed in main, but a fresh release has not yet been cut. See also #139, #140, and pysal/spaghetti#656.

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

4 participants