python中fill函数_在figu中旋转matplotlib的fill函数

我在试着做一个三人合谋。其中一个绘图框相对于另一个旋转90度,并垂直于另一个绘图的轴。所以我可以在这个帧中绘制一个直方图图,但是当我使用kde生成数据并使用fill覆盖到{}时,它不会旋转。在import pylab as plt

import seaborn as sns

from scipy.stats import gaussian_kde

import numpy as np

from astroML.plotting import hist

from mpl_toolkits.axes_grid1 import make_axes_locatable

sns.set_style("ticks")

axScatter = plt.subplot(111)

xmin, xmax = x.min(), x.max()

ymin, ymax = y.min(), y.max()

# Peform the kernel density estimate

xx, yy = np.mgrid[xmin:xmax:100j, ymin:ymax:100j]

positions = np.vstack([xx.ravel(), yy.ravel()])

values = np.vstack([x, y])

kernel = gaussian_kde(values)

f = np.reshape(kernel(positions).T, xx.shape)

axScatter.set_xlim(xmin, xmax)

axScatter.set_ylim(ymin, ymax)

# Contourf plot

cfset = axScatter.contourf(xx, yy, f, cmap='Blues')

## Or kernel density estimate plot instead of the contourf plot

#ax.imshow(np.rot90(f), cmap='Blues', extent=[xmin, xmax, ymin, ymax])

# Contour plot

cset = axScatter.contour(xx, yy, f, colors='k')

# Label plot

axScatter.scatter(x, y, marker='o', s=1, alpha=0.2, color='k')

axScatter.set_aspect('auto')

axScatter.set_xlabel(r'$X$')

axScatter.set_ylabel(r'$Y$')

# create new axes on the right and on the top of the current axes.

divider = make_axes_locatable(axScatter)

axHistx = divider.append_axes("top", size=1.2, pad=0.1, sharex=axScatter)

axHisty = divider.append_axes("right", size=1.2, pad=0.1, sharey=axScatter)

# the scatter plot:

# histograms

kde = gaussian_kde(x)

X_plot = np.linspace(xmin, xmax, 1000)

X_dens = kde.evaluate(X_plot)

axHistx.fill(X_plot, X_dens, fc='#AAAAFF',alpha=0.2)

hist(x, bins='knuth', ax=axHistx, color='black', histtype='step', normed=True)

kde = gaussian_kde(y)

Y_plot = np.linspace(ymin,ymax, 1000)

Y_dens = kde.evaluate(Y_plot)

axHisty.fill(Y_plot, Y_dens, fc='#AAAAFF' ,alpha=0.2)

hist(y, bins='knuth', ax=axHisty, color='black', histtype='step', normed=True, orientation='horizontal')

如何旋转右面板中的填充功能?在

#模块导入 import pygame,sys from pygame.locals import* #初始化pygame pygame.init() #设置窗口大小,单位是像素 screen = pygame.display.set_mode((500,400)) #设置背景颜色 screen.fill((0,0,0)) #设置窗口标题 pygame.display.set_caption("你好,我的朋友") # 绘制一条线 pygame.draw.rect(screen, (0,0,0), [0,100,70,40]) #加载图片 img = pygame.image.load("panda.jpg") #初始化图片位置 imgx = 0 imgy = 10 #加载和播放音频 sound = pygame.mixer.Sound('Sound_Of_The_Sea.ogg') sound.play() #加载背景音乐 pygame.mixer.music.load('TEST1.mp3') #播放背景音乐,第一个参数为播放的次数(-1表示无限循环),第二个参数是设置播放的起点(单位为秒) pygame.mixer.music.play(-1, 30.0) #导入文字格式 fontt=pygame.font.Font(None,50) #配置文字 tex=fontt.render("It is boring!!!",True,(0,0,128),(0,255,0)) #显示文字及坐标 texr=tex.get_rect() texr.center=(10,250) #初始化方向 dire = "right" #设置循环 while 1: #绘制文字 screen.blit(tex,texr) screen.fill((0,0,0)) screen.blit(img,(imgx,imgy)) if dire == "right": imgx+=5 if imgx == 380: dire = 'down' elif dire == 'down': imgy += 5 if imgy == 300: dire = 'left' elif dire == 'left': imgx -= 5 if imgx == 10: dire = 'up' elif dire == 'up': imgy -= 5 if imgy == 10: dire = 'right' #获取事件 for ss in pygame.event.get(): #判断事件 if ss.type == QUIT: #退出Pygame pygame.quit() #退出系统 sys.exit() #绘制屏幕内容 pygame.display.update() #设置帧率 pygame.time.delay(10)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值