+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

2020-04(20)

2020-05(26)

2020-06(39)

2020-07(33)

2020-08(50)

Matplotlib自学打卡day5

发布于2021-04-03 19:56     阅读(312)     评论(0)     点赞(3)     收藏(5)


0

1

2

3

4

5

6

7

Matplotlib自学打卡day5

pcolormesh

import matplotlib.pyplot as plt

import numpy as np

np.random.seed(19860801)

Z = np.random.rand(3, 5)  # C is a parameter in the pcolormesh, it should at least smaller than the len of x, y.
# there is a problem i can't solve.
# x = np.arange(-0.5, 10, 1)  # len = 11
# y = np.arange(4.5, 11, 1)  # len = 7
x = np.arange(-0.5, 10, 2)  # len = 6
y = np.arange(4.5, 11, 2)  # len = 4
plt.pcolormesh(x, y, Z)
fig, ax = plt.subplots()
x1, y1 = np.meshgrid(x, y)
x1 = x1 + (0.2 * y1)
y1 = y1 + (.3 * x1)
plt.pcolormesh(x1, y1, Z)
plt.show()

Center Coordinate

import matplotlib.pyplot as plt
import matplotlib
from matplotlib.ticker import MaxNLocator
from matplotlib.colors import BoundaryNorm
import numpy as np
np.random.seed(19860801)

Z = np.random.rand(6, 10)
x = np.arange(-0.5, 10, 1)
y = np.arange(4.5, 11, 1)
plt.pcolormesh(x, y, Z)
x1, y1 = np.meshgrid(x, y)
x1 = x1 + (y1*0.2)
y1 = y1 + (x1 * 0.2)
plt.pcolormesh(x1, y1, Z)

Z = np.random.rand(6, 10)
fig, ax = plt.subplots(2, 1, sharex=True, sharey=True)
x = np.arange(10)
y = np.arange(6)
x2, y2 = np.meshgrid(x, y)
ax[1].pcolormesh(x2, y2, Z, vmin=np.min(Z), vmax=np.max(Z), shading='auto')
ax[1].set_title('auto')
ax[0].pcolormesh(x2, y2, Z[:-1, :-1], vmin=np.min(Z), vmax=np.max(Z), shading='flat')
ax[0].set_title('flat')


plt.show()

0

1

2

3

4

5

6

7

8

9



所属网站分类: 技术文章 > 博客

作者:丸子

链接: https://www.pythonheidong.com/blog/article/915674/fd3d95f2e6628c1fbd42/

来源: python黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

3 0
收藏该文
已收藏

评论内容:(最多支持255个字符)