标签: scatter-plot

使用Colorbar的Matplotlib 3D散点图

从借款例如在Matplotlib文档页面上,并稍微修改代码,

import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt

def randrange(n, vmin, vmax):
    return (vmax-vmin)*np.random.rand(n) + vmin

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
n = 100
for c, m, zl, zh in [('r', 'o', -50, -25), ('b', '^', -30, -5)]:
    xs = randrange(n, 23, 32)
    ys = randrange(n, 0, 100)
    zs = randrange(n, zl, zh)
    cs = randrange(n, 0, 100)
    ax.scatter(xs, ys, zs, c=cs, marker=m)
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')

plt.show()
Run Code Online (Sandbox Code Playgroud)

将给出每个点具有不同颜色的3D散点图(在该示例中为随机颜色).将颜色条添加到图中的正确方法是什么,因为添加 …

python 3d matplotlib scatter-plot

24
推荐指数
2
解决办法
3万
查看次数

如何用R标记散点图上的点?

我是R的新手,想知道如何在散点图上标记数据点.我尝试了以下代码,但我收到错误.

x = c(102856,17906,89697,74384,91081,52457,73749,29910,75604,28267,122136,
      54210,48925,58937,76281,67789,69138,18026,90806,44893)
y = c(2818, 234, 2728, 2393, 2893, 1015, 1403, 791, 2243, 596, 2468, 1495,
      1232, 1746, 2410, 1791, 1706, 259, 1982, 836)

plot(x, y, main="Scatterplot ", xlab="xaxis ", ylab="yaxis ", pch=19)

names = c("A","C","E","D","G","F","I","H","K","M","L","N","Q","P","S","R",
          "T","W","V","Y")

library(calibrate)
textxy(x, y, labs=names, cx = 0.5, dcol = "black", m = c(0, 0))

Error in text.default(X[posXposY], Y[posXposY], labs[posXposY], adj = c(-0.3,  :
plot.new has not been called yet
Run Code Online (Sandbox Code Playgroud)

我不明白这个错误.请帮我

r scatter-plot

24
推荐指数
4
解决办法
9万
查看次数

C++中的散点图

在C++中绘制散点图的最佳方法是什么?

您是否将数据写入文件并使用其他工具?在Python中是否有类似matplotlib的库?

c++ data-visualization scatter-plot

23
推荐指数
4
解决办法
7万
查看次数

Python matplotlib叠加散点图

我正在使用Python matplotlib.我想叠加散点图.我知道如何用命令叠加连续线图:

>>> plt.plot(seriesX)
>>> plt.plot(Xresampl)
>>> plt.show()
Run Code Online (Sandbox Code Playgroud)

但它似乎与散射的工作方式不同.或者可以使用plot()和另一个指定线条样式的参数.如何进行?谢谢

python plot matplotlib scatter-plot

23
推荐指数
2
解决办法
6万
查看次数

MATLAB - 在散点图上绘制多个数据集

我有两组数据,(Ax,Ay; Bx,By).我想在具有不同颜色的散点图上绘制这两个数据集,但我似乎无法使其工作,因为它似乎scatter()不起作用plot().是否有可能做到这一点?

我试过了...

scatter(Ax, Ay, 'g', Bx, By, 'b')
Run Code Online (Sandbox Code Playgroud)

scatter(Ax, Ay, 'g')
scatter(Bx, By, 'b')
Run Code Online (Sandbox Code Playgroud)

第一种方式返回错误.后者只绘制Bx/ By数据.

matlab scatter-plot

22
推荐指数
2
解决办法
9万
查看次数

在matplotlib中重叠点的散点图的可视化

我必须在matplotlib的散点图中表示大约30,000个点.这些点属于两个不同的类,所以我想用不同的颜色描绘它们.

我成功了,但是有一个问题.这些点在许多地区重叠,我最后描绘的类将在另一个上面可视化,隐藏它.此外,散点图无法显示每个区域中有多少点.我还试图用histogram2d和imshow制作一个二维直方图,但很难以清晰的方式显示属于这两个类的点.

你能否提出一种方法来明确课程的分布和分数的集中?

编辑:更清楚,这是我的数据文件的 链接,格式为"x,y,class"

python plot visualization matplotlib scatter-plot

22
推荐指数
2
解决办法
2万
查看次数

如何将数据椭圆叠加在ggplot2散点图上?

我有一个R函数,它为散点图产生95%置信度椭圆.输出看起来像这样,每个椭圆(50行)默认为50个点:

           [,1]         [,2]
 [1,]  0.097733810  0.044957994
 [2,]  0.084433494  0.050337990
 [3,]  0.069746783  0.054891438
Run Code Online (Sandbox Code Playgroud)

我想在ggplot2散点图上为每个级别的一个名为'site'的因子叠加一些这样的省略号,由这个命令生成:

> plat1 <- ggplot(mapping=aes(shape=site, size=geom), shape=factor(site)); plat1 + geom_point(aes(x=PC1.1,y=PC2.1))
Run Code Online (Sandbox Code Playgroud)

这是在一个数据集上运行,调用dflat如下所示:

site      geom         PC1.1        PC2.1       PC3.1        PC1.2       PC2.2
1 Buhlen 1259.5649 -0.0387975838 -0.022889782  0.01355317  0.008705276  0.02441577
2 Buhlen  653.6607 -0.0009398704 -0.013076251  0.02898955 -0.001345149  0.03133990
Run Code Online (Sandbox Code Playgroud)

结果很好,但是当我尝试添加椭圆时(假设这个网站叫做"Buhlen"):

> plat1 + geom_point(aes(x=PC1.1,y=PC2.1)) + geom_path(data=subset(dflat, site="Buhlen"),mapping=aes(x=ELLI(PC1.1,PC2.1)[,1],y=ELLI(PC1.1,PC2.1)[,2]))
Run Code Online (Sandbox Code Playgroud)

我收到一条错误消息: "Error in data.frame(x = c(0.0977338099339815, 0.0844334944904515, 0.0697467834016782, : arguments imply differing number of rows: 50, 211

我过去曾设法解决这个问题,但我不记得怎么做了.似乎geom_path依赖于相同的点而不是绘制新的点.任何帮助,将不胜感激.

r ellipse scatter-plot ggplot2

21
推荐指数
2
解决办法
2万
查看次数

在Python中绘制三维散点的任何简单方法都可以旋转?

目前我正在使用matplotlib来绘制三维散点图,当它完成工作时,我似乎无法找到一种方法来旋转它以更好地查看我的数据.

这是一个例子:

import pylab as p
import mpl_toolkits.mplot3d.axes3d as p3

#data is an ndarray with the necessary data and colors is an ndarray with
#'b', 'g' and 'r' to paint each point according to its class

...

fig=p.figure()
ax = p3.Axes3D(fig)
ax.scatter(data[:,0], data[:,2], data[:,3], c=colors)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
fig.add_axes(ax)
p.show()
Run Code Online (Sandbox Code Playgroud)

我想要一个解决方案,让我在执行期间执行它,但只要我可以旋转它,它很短/快我很好用它.

以下是将PCA应用于虹膜数据集后生成的图表的比较:
1.mayavi
替代文字
2. matplotlib
替代文字

Mayavi可以更容易地显示数据,但MatPlotLib看起来更专业.Matplotlib也更轻.

python charts matplotlib scatter-plot

21
推荐指数
2
解决办法
3万
查看次数

更改matplotlib 3D绘图的轴平面的背景颜色

在matplotlib 的散点图示例的基础上,如何更改3轴网格平面的灰色背景颜色?我想将其设置为白色,使网格线保持默认的灰色.我发现了这个问题,但我无法将其应用于示例.谢谢.

python 3d matplotlib scatter-plot

21
推荐指数
2
解决办法
2万
查看次数

How to disable legend in nvd3 or limit it's size

I'm using nvd3 and have a few charts where the legend is much to large. E.g. a scatter/bubble with 15 groups and the group names are long. The legend is so large that it leaves almost no room for the chart itself.

Is there a way to remove the legend or toggle the legend or limit the height/width it is taking up? Any example would be great.

Also, is there a way to have the bubble show a descriptive string? …

bubble-chart legend scatter-plot d3.js nvd3.js

20
推荐指数
1
解决办法
2万
查看次数