可以像这样生成垂直颜色条(简化):
import matplotlib.pyplot as plt
import matplotlib as mpl
plt.figure()
c_ax=plt.subplot(111)
cb = mpl.colorbar.ColorbarBase(c_ax,orientation='vertical')
plt.savefig('my_colorbar.png')
Run Code Online (Sandbox Code Playgroud)
是否可以在对面获得刻度标签?
假设我想有大小的numpy的阵列(n,m)
,其中n
是非常大的,但有很多重复,即.0:n1
是相同的,n1:n2
是相同的等(有n2%n1!=0
,但不是规则的间隔).有没有办法只为每个重复项存储一组值,同时拥有整个数组的视图?
例:
unique_values = np.array([[1,1,1], [2,2,2] ,[3,3,3]]) #these are the values i want to store in memory
index_mapping = np.array([0,0,1,1,1,2,2]) # a mapping between index of array above, with array below
unique_values_view = np.array([[1,1,1],[1,1,1],[2,2,2],[2,2,2],[2,2,2], [3,3,3],[3,3,3]]) #this is how I want the view to look like for broadcasting reasons
Run Code Online (Sandbox Code Playgroud)
我计划将数组(视图)乘以其他一些大小的数组(1,m)
,并取这个产品的点积:
other_array1 = np.arange(unique_values.shape[1]).reshape(1,-1) # (1,m)
other_array2 = 2*np.ones((unique_values.shape[1],1)) # (m,1)
output = np.dot(unique_values_view * other_array1, other_array2).squeeze()
Run Code Online (Sandbox Code Playgroud)
输出是长度为1D的数组n
.
我有一个二维数组(如果你愿意,还有矩阵),其中一些缺失值表示为
NaN
.缺失值通常沿一个轴的条带,例如:
1 2 3 NaN 5
2 3 4 Nan 6
3 4 Nan Nan 7
4 5 Nan Nan 8
5 6 7 8 9
Run Code Online (Sandbox Code Playgroud)
在哪里我想NaN
用一些有意义的数字代替's.
我查看了delaunay三角测量,但发现文档很少.
我尝试使用astropy
's convolve,因为它支持使用2d数组,而且非常简单.这个问题是卷积不是插值,它将所有值移向平均值(可以通过使用窄内核来减轻).
这个问题应该是这篇文章的自然二维扩展.有没有办法NaN
在2d阵列中插入/丢失值?
我想使用matplotlib和pynput近乎实时地绘制鼠标的移动,但我怀疑我遇到了一些被阻止的代码问题.代码是使用此答案的简化版本.
import matplotlib.pyplot as plt
from pynput import mouse
from time import sleep
fig, ax = plt.subplots()
ax.set_xlim(0, 1920-1)
ax.set_ylim(0, 1080-1)
plt.show(False)
plt.draw()
x,y = [0,0]
points = ax.plot(x, y, 'o')[0]
# cache the background
background = fig.canvas.copy_from_bbox(ax.bbox)
def on_move(x, y):
points.set_data(x,y)
# restore background
fig.canvas.restore_region(background)
# redraw just the points
ax.draw_artist(points)
# fill in the axes rectangle
fig.canvas.blit(ax.bbox)
with mouse.Listener(on_move=on_move) as listener:
sleep(10)
Run Code Online (Sandbox Code Playgroud)
代码似乎停止了ax.draw_artist(points)
.pynput鼠标侦听器是a threading.Thread
,并且从线程调用所有回调.我对matplotlib或线程的内部工作原理不太熟悉,无法确定原因.
在简单的散景演示示例slider.py
(演示)中,可以应用调整大小工具来扩展绘图.
但是,如果增加宽度,则绘图首先占用滑块小部件占用的空间,然后开始向右展开:
有没有办法防止这种行为?
小部件在a中VBoxForm
,我认为问题在于(t):
inputs = VBoxForm(children=[text, offset, amplitude, phase, freq])
curdoc().add_root(HBox(children=[inputs, plot], width=800))
Run Code Online (Sandbox Code Playgroud)
如何使散景保留小部件大小,或者左对齐绘图(这样我可以在不改变初始外观的情况下增加容器的大小)?
我正在尝试侦听线性调频(使用webassembly 16kHz-mono 3.1.0版本),同时通过WebRTC与辅助设备进行通信,而WebRTC也在侦听线性调频。
在两个设备已连接并且彼此之间传输声音的情况下,如果我实例化一个Chirp并调用chirp.start()
,则不再有任何回声消除,即。回声发生。如何在两个设备之间没有回声的情况下方便使用线性调频?
为了澄清,我不想通过WebRTC传输线性调频信号,而是打算在传输之前滤除频谱的那部分。
使用适用于WebRTC的opentok.js在多个操作系统上的Chrome 75.0上进行了测试。
python ×6
matplotlib ×3
bokeh ×2
numpy ×2
chirp ×1
colorbar ×1
colormap ×1
javascript ×1
opentok ×1
pynput ×1
scatter-plot ×1
webrtc ×1