|
From: ChaoYue <cha...@gm...> - 2014-03-02 11:02:29
|
Dear Eric, This solved part of my problem. thanks a lot. I think I will revisit this issue when I have time (not promised). do you think this could be some feature desirable? Cheers, Chao On Sat, Mar 1, 2014 at 10:39 PM, Eric Firing [via matplotlib] < ml-...@n5...> wrote: > On 2014/03/01 11:03 AM, ChaoYue wrote: > > The most correct way might be to design a new colormap with white color > > exactly in the middle, however this is very tedious, especially if I > > want to try > > different colormaps. so the alternative approach would be to set the > values > > falling in (-1,1) as being masked, so they will be the same as the axes > > background color as you mentioned (in our case it's white). My question > is, > > how can I put this background color (which shows maksed data) in the > > colorbar, > > by avoiding design a new colormap? > > It's not the answer you want to hear, but I think the correct answer is > that you should do this via the colormap, and not by masking the low > values. It doesn't have to be painful. If, in contourf, you use a > diverging colormap with white already in the middle > (http://matplotlib.org/examples/color/colormaps_reference.html) and a > norm with symmetric limits (vmin and vmax; you can let them be set > automatically after you specify your symmetric set of contour boundaries > appropriately) then it will be done for you. > > e.g., > > z = 10 * np.random.randn(20, 30) > clevs = [-10, -5, -2, -1, 1, 2, 5, 10] > cs = plt.contourf(z, levels=clevs, cmap=plt.get_cmap('PRGn'), > extend='both') > cbar = plt.colorbar(cs, spacing='uniform') > > Eric > > ------------------------------------------------------------------------------ > > Flow-based real-time traffic analytics software. Cisco certified tool. > Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer > Customize your own dashboards, set traffic alerts and generate reports. > Network behavioral analysis & security monitoring. All-in-one tool. > > http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk > _______________________________________________ > Matplotlib-users mailing list > [hidden email] <http://user/SendEmail.jtp?type=node&node=42952&i=0> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > > http://matplotlib.1069221.n5.nabble.com/How-can-I-put-a-white-area-in-the-middle-of-colorbar-showing-the-masked-data-tp42948p42952.html > To start a new topic under matplotlib - users, email > ml-...@n5... > To unsubscribe from matplotlib, click here<http://matplotlib.1069221.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=2&code=Y2hhb3l1ZWpveUBnbWFpbC5jb218MnwxMzg1NzAzMzQx> > . > NAML<http://matplotlib.1069221.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > -- *********************************************************************************** Chao YUE Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL) UMR 1572 CEA-CNRS-UVSQ Batiment 712 - Pe 119 91191 GIF Sur YVETTE Cedex Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16 ************************************************************************************ -- View this message in context: http://matplotlib.1069221.n5.nabble.com/How-can-I-put-a-white-area-in-the-middle-of-colorbar-showing-the-masked-data-tp42948p42956.html Sent from the matplotlib - users mailing list archive at Nabble.com. |