Re: [Matplotlib-users] Easiest way to create a chloropleth in Python

2014-11-16 Thread Christian Alis
Thanks! I did use geopandas and it seems it is the easiest method of
creating a choropleth in Python. Support for displaying a colorbar for
noncategorical data is missing so I implemented it but my PR hasn't
been merged yet.

On Fri, Nov 14, 2014 at 6:07 PM, Benjamin Root  wrote:
> Sorry for the delay. Here is an example I came across today using geopandas
> and pysal:
> http://nbviewer.ipython.org/github/geopandas/geopandas/blob/master/examples/choropleths.ipynb
>
> Cheers!
> Ben Root
>
> On Fri, Oct 24, 2014 at 3:59 PM, Christian Alis  wrote:
>>
>> Hi Ben,
>>
>> Yes, indeed. I'm referring to a choropleth. :)
>>
>> Thanks,
>>
>> Christian
>>
>> On Oct 24, 2014 8:23 PM, "Benjamin Root"  wrote:
>>>
>>> Do you mean choropleth? http://en.wikipedia.org/wiki/Choropleth_map
>>>
>>> On Fri, Oct 24, 2014 at 1:18 PM, ianalis  wrote:

 I have been creating chloropleth maps in Python by adding patches and/or
 polygons in a matplotlib Axes but I'm looking for something easier to
 use.

 Ideally, the interface should be similar to how contour maps or
 pseudocolor
 plots are created where, at the minimum, only one call to a function is
 needed to create these plots from data. Colors are automatically
 assigned
 and normalized based on values. A colorbar can then be added by calling
 another function.

 So far, the closest package seems to be geopandas. Is there an another
 package that is nearer to what I want? That is, is there a package that
 can
 make a (basic) chloropleth of values stored as a dictionary, numpy array
 or
 pandas dataframe in one call?

 I'm willing to contribute code and help develop the chloropleth
 capability
 of a package since I currently end up creating my own function and
 manipulating Axes internals just to create a chloropleth.



 --
 View this message in context:
 http://matplotlib.1069221.n5.nabble.com/Easiest-way-to-create-a-chloropleth-in-Python-tp44195.html
 Sent from the matplotlib - users mailing list archive at Nabble.com.


 --
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>>
>

--
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] [matplotlib-devel] Development issue: Assign labels to colorbar extensions

2014-11-16 Thread Eric Firing
On 2014/11/16, 10:21 AM, j1 wrote:
> I have posted this in the user sub forum as well because i'm not sure that it
> is a user issue or development issue.
> Information about my problem and my code are here
>
> http://matplotlib.1069221.n5.nabble.com/Assign-labels-to-colorbar-extensions-user-or-development-issue-td44392.html
> 
>
> Is it possible to assign tick labels/values to extensions?

You would have to do it manually; you can put marks and text anywhere 
you want in a matplotlib figure, but there is no mechanism for adding 
ticks to the extensions.  That's simply not what they are for.  They are 
intended only to indicate a single color to which values outside the 
vmin-to-vmax range of the norm are assigned.

>
> If so, how can I do it

It looks like you might be able to achieve what you want *without* using 
extensions, by using a custom colormap and/or norm.  You would extend 
the actual contour levels to include the full range you want "ticked and 
labeled", but you would use the colormap and/or norm to ensure those 
beyond a given range are mapped to the appropriate end color(s).

Eric



--
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Assign labels to colorbar extensions (user or development issue)

2014-11-16 Thread j1
I am not sure if this is a user issue or a development issue.
Using version 1.4.2
My code allows the user to hone in on a specific contour range, by changing
the minimum and maximum of the contour and the number of levels.
I am using colorbar "extend" to prevent any white patches, as the data may
have values outside the contour range.

I want the extensions to have tick values but I can't seem to figure out,
how to do it?

This is my code

import numpy as np
import matplotlib.pyplot as plt
xi = np.array([0., 0.5, 1.0])#xi data
yi = np.array([0., 0.5, 1.0])#yi data
zi = np.array([[0., 1.0, 2.0],[0., 1.0, 2.0],[-0.1, 1.0, 2.0]])#zi data
n=5#number of levels of user specified range
umin=0.5#user defined minimum of contour
umax=1#user defined maximum of contout
u = np.linspace(umin, umax, n)#user specified contour levels
cbtics = np.hstack([zi.min(),u,zi.max()])#contour ticks including maximum
and minimum of zi
plt.contourf(xi, yi, zi, u, cmap=plt.cm.jet,extend='both')#plot contour
cbar=plt.colorbar(extendrect='True',extendfrac='auto',spacing='proportional')#plot
colorbar
print cbar.ax.get_ylim()#show y limits
print cbar.ax.get_yticks()#show yticks
plt.show()


Using the user entered values:
ylim are (-0.25, 1.25)
but the yticks are:
[ 0.   0.2  0.4  0.6  0.8  1. ] range from 0 to 1

I'm guessing that the difference between ylim (-0.25 to 1.25) and yticks (0
to 1) is that I am using extensions, so is there no way to update y ticks to
include the extensions so that I can  assign labels to the extensions?



--
View this message in context: 
http://matplotlib.1069221.n5.nabble.com/Assign-labels-to-colorbar-extensions-user-or-development-issue-tp44392.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

--
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users