Skip to content

Colors are not fixed is LISA maps #80

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

Closed
serenini opened this issue Jul 20, 2019 · 11 comments
Closed

Colors are not fixed is LISA maps #80

serenini opened this issue Jul 20, 2019 · 11 comments
Assignees

Comments

@serenini
Copy link

When I create a map that does have regions in the 4 classes, the colors are ok (Light blue used to LH):
image

But when I create a map that does not have regions in each of the 4 categories, the colors are changed (orange used to LH):
image

How can I fix the colors to compare the same map in different times?

@sjsrey
Copy link
Member

sjsrey commented Jul 20, 2019

@alvinegro can you add a code snippet so we can help debug?

@serenini
Copy link
Author

@sjsrey I have a dictionary called "separado_rgi" with dfs from 2002 to 2017.
I want to create LISA maps from the variable "rendimento" to compare each year.
I created a LISA map for each year:

import pysal as ps
from pysal.explore.esda import Moran, Moran_Local

w = Queen.from_shapefile('dados/RG2017_rgi.shp')
lisa =Moran_Local(separado_rgi[2003].rendimento, w)
lisa_cluster(lisa, separado_rgi[2003], p=0.05, legend=True);

The first code above, generated this map:
image

In 2003, there was significant regions in all the 4 categories, but, in some years (e.g. 2006) some categories does not have any region with significance level. So when I created the map, the colors related to each category was changed (now, LH is orange, istead of lightblue):
lisa =Moran_Local(separado_rgi[2006].rendimento, w)
lisa_cluster(lisa, separado_rgi[2006], p=0.05, legend=True);
image

I would like that the colors be the same for all over the years, so it would be possible to compare the evolution of the clusters.

@serenini serenini changed the title Colros are not fixed is LISA maps Colors are not fixed is LISA maps Jul 20, 2019
@sjsrey sjsrey transferred this issue from pysal/pysal Jul 20, 2019
@sjsrey
Copy link
Member

sjsrey commented Jul 21, 2019

I can't reproduce this on other examples, so a couple of options:
In the call:
lisa_cluster(lisa, separado_rgi[2003], p=0.05, legend=True)
the second argument should be a geodataframe. Can you try changing this to see if the result is what you are looking for?

If that doesn't work, can you send your data so I can debug locally?

@slumnitz
Copy link
Member

Hello @alvinegro, which splot release are you using? already v1.1.1? If not then this could be fixed by using the most up to date version. If it is still a problem, I know where the bug is. Just let me know.

@sjsrey
Copy link
Member

sjsrey commented Jul 21, 2019

I can't reproduce this on other examples, so a couple of options:
In the call:
lisa_cluster(lisa, separado_rgi[2003], p=0.05, legend=True)
the second argument should be a geodataframe. Can you try changing this to see if the result is what you are looking for?

If that doesn't work, can you send your data so I can debug locally?

I misread your earlier response, and now see you are passing a geodataframe in the second argument. So, I can check things locally if you are able to share the data.

@serenini
Copy link
Author

@slumnitz how can I check or update the version of the splot release?

@serenini
Copy link
Author

@sjsrey I sent the data to your e-mail

@slumnitz
Copy link
Member

if you used pip for the installation: pip install —upgrade splot

if you used conda: conda update splot

@serenini
Copy link
Author

@slumnitz I updated the splot to version 1.1.1 but the problem persists

@slumnitz
Copy link
Member

hello @alvinegro, I am sorry, but I cannot reproduce your error. Sorting the right label with the right colour works for all of my datasets:

image

I would highly recommend double checking your splot version number again. Potentially reinstalling splot if the update did not work for you. Note: the new splot version is only included in the newest PySAL release.

Otherwise, feel free to also share your data with me and I can see if I can get it working or get it debuged.

@serenini
Copy link
Author

Hello @slumnitz ! I noticed that you already solved this problem at #73 , so I coppied the code of lisa_cluster and mask_local_auto on another .py file, so I imported lisa_cluter from it and worked.
I will try to reinstall splot.
Anyway, thank you very much for your help!

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

3 participants