我想为我的散点图指定类似于excel的x轴的比例.
例如,我输入x轴值如下:
x_values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
Run Code Online (Sandbox Code Playgroud)
但是,只显示偶数为1位的数字.
有没有办法让所有数字出现在x轴上?
谢谢,
PARTH
如何使用核心图绘制带有间隙的散点图?我正在使用核心绘图库.一切都工作正常,但现在我想在数据线的开头或中间做一个带有间隙的散点图?有人帮帮我吗?
与一篇热门帖子类似,我想修改以下代码(来自R文档中的examples ()命令示例):
## put (absolute) correlations on the upper panels,
## with size proportional to the correlations.
panel.cor <- function(x, y, digits = 2, prefix = "", cex.cor, ...)
{
usr <- par("usr"); on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
r <- abs(cor(x, y))
txt <- format(c(r, 0.123456789), digits = digits)[1]
txt <- paste0(prefix, txt)
if(missing(cex.cor)) cex.cor <- 0.8/strwidth(txt)
text(0.5, 0.5, txt, cex = cex.cor * r)
}
pairs(USJudgeRatings, lower.panel = panel.smooth, upper.panel = …Run Code Online (Sandbox Code Playgroud) 如何将逻辑回归结果的统计图添加到散点图中?我想要彩色的0/1区域,该区域描绘了分类器的决策边界。
import pandas as pd
import numpy as np
import pylab as pl
import statsmodels.api as sm
# Build X, Y from file
f = open('ex2data2.txt')
lines = f.readlines()
x1 = []
x2 = []
y = []
for line in lines:
line = line.replace("\n", "")
vals = line.split(",")
x1.append(float(vals[0]))
x2.append(float(vals[1]))
y.append(int(vals[2]))
x1 = np.array(x1)
x2 = np.array(x2)
y = np.array(y)
x = np.vstack([x1, x2]).T
# Scatter plot 0/1s
pos_mask = y == 1
neg_mask = y == 0
pos_x1 …Run Code Online (Sandbox Code Playgroud) 我发现的每个例子都显示所有散点图都是随机半径.有可能让它们大小相同吗?如果我尝试静态设置半径,则所有圆圈都将非常小(我假设默认半径).但是,如果我在大多数示例中使用Math.random(),则会有大小的圆圈.我希望所有的圈子都很大.有没有办法做到这一点?这是使用Math.random()形成图数据的代码片段(由于某种原因,这可以正常工作):
function scatterData(xData, yData)
{
var data = [];
for (var i = 0; i < seismoNames.length; i++)
{
data.push({
key: seismoNames[i],
values: []
});
var xVals=""+xData[i];
xVals=xVals.split(",");
var yVals=""+yData[i];
yVals=yVals.split(",");
for (var j = 0; j < xVals.length; j++)
{
data[i].values.push({
x: xVals[j],
y: yVals[j],
size: Math.random()
});
}
}
return data;
}
Run Code Online (Sandbox Code Playgroud)
Math.random()吐出0到1之间的值,例如0.164259538891095和0.9842195005008699.我已经尝试将这些作为静态值放在'size'属性中,但不管圆圈总是很小.有什么我想念的吗?
如何使用java中的jfreechart在mysql数据库表中绘制数据的散点图.我用过swing库.任何链接都会有所帮助.我搜索谷歌但无法找到理解解决方案.如果你有代码,请提供给我.实际上我做了barchart并使用jfreechart绘制它.我用于条形图的代码就在这里.这里display3函数显示条形图.如何修改它以显示散点图?
public void display3() throws SQLException, ClassNotFoundException{
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
String JDBC_DRIVER="com.mysql.jdbc.Driver";
String DB_URL="jdbc:mysql://localhost/data2";
Connection conn;
Statement stmt;
String USER = "root";
String PASS = "";
try{
Class.forName(JDBC_DRIVER);
conn=DriverManager.getConnection(DB_URL,USER,PASS);
System.out.println("Creating statement...");
stmt = conn.createStatement();
String sql;
sql="SELECT * FROM `production` WHERE crop_id = 1 AND location_id = 1";
ResultSet rs=stmt.executeQuery(sql);
while (rs.next()){
//String student = rs.getString("studentname");
String yeartext = rs.getString("year_of_production");
//double value = Double.parseDouble(text);
String productiontext = rs.getString("production_amount");
double production = Double.parseDouble(productiontext);
Integer year = Integer.parseInt(yeartext);
dataset.setValue(production, "production", …Run Code Online (Sandbox Code Playgroud) 我有一个散点图:
fig,ax = plt.subplots(figsize=(6,5),dpi=200)
ax.scatter(df1['id'],df1['resellers'],c='red',s=df1['ips']/80,label='AS Size = IPs seen in dnsdb')
ax.set_xticks([1,2,4,6,8,10,12,14,16,18,20])
ax.set_xlim(-1,22)
ax.legend(
scatterpoints=1,
loc='best',
ncol=1,
fontsize=12)
Run Code Online (Sandbox Code Playgroud)
我想知道如何将图例中气泡的形状和大小更改为矩形和更小的尺寸.有人可以帮忙吗?
我正在尝试从以下字典中绘制散点图:
data_dict = {12: [1, 17, 11, 17, 1, 14, 38], 13: [13, 6, 4, 6], 14: [15, 8, 20, 8, 7], 15: [2, 3, 3, 1], 16: [62, 13, 36, 3, 8, 99, 54], 17: [1], 18: [44, 30, 36, 14, 21, 13, 44, 1, 62, 36], 19: [5, 5], 20: [27, 42, 42, 18, 31, 55, 31, 55], 21: [59, 1, 42, 17, 66, 26, 18, 4, 36, 42, 20, 54, 44, 35]}
Run Code Online (Sandbox Code Playgroud)
我正在使用以下代码绘制散点图,其中字典键是x值,是相应的值。
for xe, ye in …Run Code Online (Sandbox Code Playgroud) 我正在使用ggplot2创建一个带有散点图叠加的分组箱图.我想将每个散点图数据点与它对应的分组框图进行分组.
但是,我也喜欢散点图是不同的符号.我似乎能够将我的散点图分组与我的分组箱图分组,或者将我的散点图点指向不同的符号......但不能同时进行.下面是一些示例代码,用于说明发生的情况:
library(scales)
library(ggplot2)
# Generates Data frame to plot
Gene <- c(rep("GeneA",24),rep("GeneB",24),rep("GeneC",24),rep("GeneD",24),rep("GeneE",24))
Clone <- c(rep(c("D1","D2","D3","D4","D5","D6"),20))
variable <- c(rep(c(rep("Day10",6),rep("Day20",6),rep("Day30",6),rep("Day40",6)),5))
value <- c(rnorm(24, mean = 0.5, sd = 0.5),rnorm(24, mean = 10, sd = 8),rnorm(24, mean = 1000, sd = 900),
rnorm(24, mean = 25000, sd = 9000), rnorm(24, mean = 8000, sd = 3000))
value <- sqrt(value*value)
Tdata <- cbind(Gene, Clone, variable)
Tdata <- data.frame(Tdata)
Tdata <- cbind(Tdata,value)
# Creates the Plot of All Data
# The below code groups …Run Code Online (Sandbox Code Playgroud) 我是Pandas的新手,我一直在尝试用Python 2.7做一个散点图,我在.txt文件中的数据集是这样的(逗号分隔)
6.1101,17.592
5.5277,9.1302
8.5186,13.662
7.0032,11.854
5.8598,6.8233
8.3829,11.886
7.4764,4.3483
import pandas as pd
import matplotlib.pyplot as mplt
# Taking Dataset using Pandas
input_data = pd.read_csv('data.txt');
#input_data.head(5)
Run Code Online (Sandbox Code Playgroud)
如何在数据集上没有任何标题的散点图中绘制上述数据?
我在教程和示例中看到,如果数据集具有列标题,则可以绘制散点图.我尝试将x和y作为.txt文件中数据集的两列的标题,并尝试以下代码.
input_data = pd.read_csv('data.txt');
#input_data.head(5)
x_value = input_data[['x']]
y_value = input_data[['y']]
mplt.scatter(x_value, y_value)
Run Code Online (Sandbox Code Playgroud)
但是我仍然会收到错误,如下所示
Traceback (most recent call last):
File "E:\IIT Madras\Research\Experiments\Machine Learning\Linear Regression\Linear_Regression.py", line 16, in <module>
y_value = input_data[['y']]
File "C:\Python27\lib\site-packages\pandas\core\frame.py", line 1791, in __getitem__
return self._getitem_array(key)
File "C:\Python27\lib\site-packages\pandas\core\frame.py", line 1835, in _getitem_array
indexer = self.ix._convert_to_indexer(key, axis=1)
File "C:\Python27\lib\site-packages\pandas\core\indexing.py", line 1112, …Run Code Online (Sandbox Code Playgroud) scatter-plot ×10
python ×5
matplotlib ×4
pandas ×2
r ×2
boxplot ×1
contour ×1
core-plot ×1
correlation ×1
d3.js ×1
ggplot2 ×1
graphing ×1
ios ×1
java ×1
javascript ×1
jfreechart ×1
legend ×1
mysql ×1
nvd3.js ×1
plotly ×1
scale ×1
swing ×1