在以下代码中,只要鼠标单击饼图,我就在控制台上打印标签。问题是由于楔块的原因,我无法将autopct添加到ax.pie()中,我不知道如何在不使用autopct的情况下在饼图上添加百分比标签。
import matplotlib.pyplot as plt
labels = ['Beans', 'Squash', 'Corn']
i=0
def main():
# Make an example pie plot
fig = plt.figure()
ax = fig.add_subplot(111)
#labels = ['Beans', 'Squash', 'Corn']
wedges, plt_labels = ax.pie([20, 40, 60], labels=labels)
ax.axis('equal')
make_picker(fig, wedges)
plt.show()
def make_picker(fig, wedges):
global i
def onclick(event):
global i
i=i+1
print event.__class__
wedge = event.artist
label = wedge.get_label()
print label
fig.canvas.figure.clf()
ax=fig.add_subplot(111)
wedges, plt_labels = ax.pie([50, 100, 60],labels=labels)# how to add autopct='%1.1f%%'
fig.canvas.draw()
for wedge in wedges:
wedge.set_picker(True)
# …Run Code Online (Sandbox Code Playgroud) 在Windows中我使用这些线条
gui = require('nw.gui');
//To open a website externally
gui.Shell.openExternal(URL);
//To execute command line
gui.Shell.openItem(commandString);
Run Code Online (Sandbox Code Playgroud)
它工作正常.同一条代码在MAC中不起作用.我在这里失踪了什么?我不想在其中创建任何文件和编写命令(批处理文件,通常称为shell脚本).有没有办法不创建批处理文件并在MAC中运行这些命令?