- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有这个非常简单的代码,它绘制了一个由 100 个点 (10,10) 组成的列表,这些点都是相同的。不幸的是,我收到一条警告和一张空白图表。
我的代码:
import matplotlib.pyplot as plt
mylist = list()
for i in range(100):
mylist.append(10)
def plot():
plt.subplot(111)
plt.hexbin(mylist,mylist,bins='log', cmap=plt.cm.YlOrRd_r)
plt.axis([0,50,0,50])
plt.show()
plot()
警告:
hexbin
中绘制相同的数据?我的具体情况:
我知道这可能是一个奇怪的问题,但我的程序正在绘制大量点 (x,y)(当然是在 hexbin
中),有时这些点可能都是相同的。
如果我稍微改变上面的代码并在 list[i]
中放入不同的点 (x,y)(i 是任何索引)代码运行良好并绘制数据。
最佳答案
问题是它试图通过查看最大和最小 x
和 y
值来猜测网格的限制,并使步长 sx = (x_max - x_min)/num_x_bins
在此输入的情况下严格为零。解决方案是使用 extent
关键字告诉代码该数组有多大。
mylist = list()
for i in range(100):
mylist.append(10)
def plot():
plt.subplot(111)
plt.hexbin(mylist,mylist,bins='log', cmap=plt.cm.YlOrRd_r, extent=[0, 50, 0, 50])
plt.axis([0,50,0,50])
plt.show()
plot()
有一个 PR 可以解决这个问题(应该在 1.4 https://github.com/matplotlib/matplotlib/pull/3038 中)
与此同时我会使用类似的东西(未经测试,这里可能有一些微不足道的错误):
import matplotlib.transfroms as mtrans
def safe_hexbin(ax, x, y, *args, **kwargs):
if 'extent' not in kwargs:
xmin = np.amin(x)
xmax = np.amax(x)
ymin = np.amin(y)
ymax = np.amax(y)
# to avoid issues with singular data, expand the min/max pairs
xmin, xmax = mtrans.nonsingular(xmin, xmax, expander=0.1)
ymin, ymax = mtrans.nonsingular(ymin, ymax, expander=0.1)
kwargs['extent'] = (xmin, xmax, ymin, ymax)
return ax.hexbin(x, y, *args, **kwargs)
safe_hexbin(plt.gca(), x, y, ...)
关于python - 是否可以在 matplotlib hexbin 图上绘制相同点的列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14780362/
我正在 basemap 图像上制作六边形热图的动画,但无法弄清楚如何在开始下一帧之前删除先前的六边形。我想用一些累积来制作动画,但以选定的时间间隔重置(我的数据有时间维度,我想显示给定年份的所有点,日
我正在绘制高密度点的散点图。我使用了 Hexbin 包并成功绘制了数据。颜色不漂亮,我被要求遵循标准颜色。我想知道 R 是否支持它。图像显示了我的输出(右)和想要的颜色(左)。 例子: x <
我总是发现一些奇怪的白色水平虚线,这些虚线似乎出现在我在 R 环境中使用 ggplot2 创建的每个 hexbin 密度图上的垂直相邻六边形之间的边界上。他们当然不属于那里......这种行为(错误)
我正在寻找一种方法来微调 hexbin 图中单个细胞的颜色。 我尝试使用来自 PolyCollection 的方法 set_facecolors改变单个单元格的颜色,但这似乎不起作用。 示例:这应该会
我一直在尝试寻找在 hexbin 图上添加黄土回归线的方法。到目前为止,我没有任何成功......有什么建议吗? 我的代码如下: bin<-hexbin(Dataset$a, Dataset$b, x
我有以下代码,可生成下图 import numpy as np np.random.seed(3) import pandas as pd import matplotlib.pyplot as pl
我有一个如下所示的数据框: df = pd.DataFrame( {"x" : [2,4,5,8,5,4,1,6,8,7], "y" : [2,4,1,3,7,8,9,3,6,9],
我正在尝试学习如何使用 d3.js hexbin 插件。 我从这个例子开始:http://bl.ocks.org/mbostock/4248145 ,我正在对其进行调整。 我有一个介于 [0,0] 和
以下代码片段基本上就是这个示例 https://bl.ocks.org/mbostock/4248145但具有自定义数据点。无论我如何缩放或修改点数组,六边形始终位于左上角,尽管分布似乎显示正确。 我
我使用的是 Bokeh 0.12.15 版本,它生成了一个很棒的 hexbin 图。我想知道如何轻松找到每个六边形值的索引? 例如下面的代码 ( https://docs.bokeh.org/en/l
我有两个数组,x 和 y,它们的值都在明确定义的范围内。我能够创建一个 hexbin 图 ( see image ),但是,我现在想对这些分布进行归一化并在它们周围绘制等高线图。我对每个 hexbin
我想用 matplotlib 制作 x y 数据的多个 hexbin 密度图,类似于这个: http://matplotlib.org/1.4.0/examples/pylab_examples/he
我在 hexbin 图中有两个分布,如图所示: 一个分布的最大值约为 4000,而另一个分布的最大值约为 2500。因此绘图颜色不同。 我在想,如果我知道 hexbin 图的最大值,我就可以对其进行归
我有一些空间分布的数据。我正在用 matplotlib.pyplot.hexbin 绘制它并想更改“背景”(即零值)颜色。下面显示了一个示例 - 我选择的颜色图是 matplotlib.cm.jet:
我正在对一个非常密集的大型数据集进行一些 KMeans 聚类,并且我正在尝试找出可视化聚类的最佳方法。 在 2D 中,它看起来像 hexbin会做得很好,但我无法在同一个数字上重叠绘制集群。我想用 h
这与另一个问题有关:Plot weighted frequency matrix . 我有这个图形(由下面的 R 代码生成): #Set the number of bets and number o
有没有办法根据频率增加 pyplot.hexbin 中六边形的相对大小?我只能看到关键字参数的 binsize,它会影响十六进制的数量,但不会影响它们的大小。 但是在this article (在“多
我有这个非常简单的代码,它绘制了一个由 100 个点 (10,10) 组成的列表,这些点都是相同的。不幸的是,我收到一条警告和一张空白图表。 我的代码: import matplotlib.pyplo
这个问题在这里已经有了答案: Hexbin plot in PairGrid with Seaborn (1 个回答) 关闭 3 年前。 我想为我的 DataFrame 中的所有列绘制成对图;然而,
我在创建两个 matplotlib.pyplot 之间的差异图时遇到了问题hexbin plots,意思是获取每个对应hexbin的值差先而后创差异hexbin map 。 在这里举一个我的问题的简单
我是一名优秀的程序员,十分优秀!