python lognorm_matplotlib等高线图与lognorm - colorbar水平 (matplotlib contour plot with lognorm - colorba...

2013-07-30 15:50:16

2

I am trying to make a contour plot with defined levels and log norm. Below is an example:

import matplotlib.pyplot as plt

import numpy as np

from matplotlib.colors import LogNorm

delta = 0.025

x = y = np.arange(0, 3.01, delta)

X, Y = np.meshgrid(x, y)

Z1 = plt.mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)

Z2 = plt.mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)

Z = 10 * (Z1* Z2)

fig=plt.figure()

ax1 = fig.add_subplot(111)

lvls = np.logspace(-4,0,20)

CF = ax1.contourf(X,Y,Z,

norm = LogNorm(),

levels = lvls

)

CS = ax1.contour(X,Y,Z,

norm = LogNorm(),

colors = 'k',

levels = lvls

)

cbar = plt.colorbar(CF, ticks=lvls, format='%.4f')

plt.show()

My questions is:

The levels should be written in the format: '1x10^-4', '1.6x10^-4', ... How do i do this, without specifying each level manually?

I am using python 2.7.3 with matplotlib 1.1.1 on Windows 7.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值