我需要在matplotlib中生成一个按钮小部件的变量数(总计),并让每个部件在变量var中存储一个不同的数字。
import matplotlib.pyplot as plt
from matplotlib.widgets import Button as BT
total = 4
class Index:
ind = 0
def plot_pick(self, event):
var=event
print(var)
ax_chooseplot={}
chooseplot_BT={}
callback=Index()
最后,我希望能够将两个圆心的位置附加到单独的列表中。但是,我定义了一个按钮来做这件事,当单击它时,它会给我一个错误。
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import matplotlib.patches as patches
from matplotlib.widgets import Button
import os
class DraggablePoint:
lock = None #only one can be animated at a time
def __init__
我试图用以下方法生成和绘制随机数:
from numpy import random
import matplotlib.pyplot as plt
z = 15 + 2*random.randn(200) #200 elements, normal dist with mean = 15, sd = 2
plt.plot(z)
plt.show(z)
图是绘制的,但是Python (2.7.5)冻结了,我得到了错误
Traceback (most recent call last):
File "G:\Stage 2 expt\e298\q1.py", line 25
我正在尝试使用python setup.py build在Python3.4上添加matplotlib-1.4.2。根据文档,它在python3.4上受支持。我收到以下错误消息:
IMPORTANT WARNING:
pkg-config is not installed.
matplotlib may not be able to find some of its dependencies
============================================================================
Edit setup.cfg to
下面的代码运行良好: Python 3.8.2 (default, Apr 8 2020, 14:31:25)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
>>> fig = plt.figure()
>>> fig.suptitle("Empty fig
我试图用x和y网格创建一个散点图,其中每个点都通过一个预先赋值的值获得颜色:
{x: 1, y: 2, value: n}
我有一个x和y的列表以及另一个值列表,尝试使用以下方法:
# make range of x(0 - 359) and y(-90 - 90)
x, y = np.meshgrid(range(0, 360), range(-90, 90))
colors = [a very long list (64800 values, one for each point)]
print(colors)
plt.scatter(x, y, c=colors)
plt.colorba
我正在尝试使用ginput来注册地图上的点击,并希望使用matplotlib小部件添加操作按钮。在下面的代码中,我可以通过将Action值声明为global来将其传回给主代码。如果我单击地图action=0,如果我根据需要单击按钮action=1。 import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Button
class Index:
def test(self, event):
global action
action=1
# fa
我使用python pyvis包来实现节点可视化。pyvis树只能在单独的html上渲染吗?我们不能使用matplotlib包进行绘图吗? from pyvis.network import Network
import pandas as pd
got_net = Network(height="750px", width="100%", bgcolor="#222222", font_color="white")
# set the physics layout of the network
got_net.barnes
我已经安装了numpy1.3,scipy 0.7.1,matplotlib 0.99.1.1和python 2.5,当我导入pylab时,我得到了以下错误。谁来帮帮忙。
/var/lib/python-support/python2.5/gtk-2.0/gtk/__init__.py:72: GtkWarning: could not open display
warnings.warn(str(e), _gtk.Warning)
/usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py:44:
python 3.10.4
在使用matplotlib 3.5.1时,我在多次调用FigureCanvasTkAgg()函数时遇到了问题。
我创建了这个虚拟python脚本来显示内存泄漏。
from tkinter import *
from matplotlib.figure import Figure
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import tracemalloc
import gc
def repeat(n, fig, root):
for i in range(n):
我是一个新的python用户,但却是一个有经验的Matlab用户。我最近在调试一个python脚本,当我多次手动重新运行该脚本时,我发现matplotlib的一个有点恼人的问题:如果图形标题相同,它总是在现有图形窗口上绘制,重叠在现有图形窗口上。
我正在调试的脚本如下所示:
import matplotlib.pyplot as plt
# Some calculations here
plt.figure('Results') # The script will only create one figure
# plot the data
# End of the scrip