R语言:
需要使用包:绘图包ggplot2、gridExtra(图形分布)、GGally(ggplot扩展,适合做成对出现图形)
library(ggplot2)
library(gridExtra)
#加载数据
iris=read.csv('../input/Iris.csv')
View(iris)
ggplot(data=iris, aes(x=Sepal.Length, y=Sepal.Width, colour=Species, shape=Species)) + geom_point()
ggplot(iris, aes(Species, Petal.Length, fill=Species)) + geom_boxplot()
HisSl <- ggplot(data=iris, aes(x=Sepal.Length))+
geom_histogram(binwidth=0.2, color="black", aes(fill=Species)) +
theme(legend.position="none")+
ggtitle("Histogram of Sepal Length")
HistSw <- ggplot(data=iris, aes(x=Sepal.Width)) +
geom_histogram(binwidth=0.2, color="black", aes(fill=Species)) +
theme(legend.position="none")+
ggtitle("Histogram of Sepal Width")
HistPl <- ggplot(data=iris, aes(x=Petal.Length))+
geom_histogram(binwidth=0.2, color="black", aes(fill=Species)) +
theme(legend.position="none")+
ggtitle("Histogram of Petal Length")
HistPw <- ggplot(data=iris, aes(x=Petal.Width))+
geom_histogram(binwidth=0.2, color="black", aes(fill=Species)) +
theme(legend.position="bottom" )+
ggtitle("Histogram of Petal Width")
grid.arrange(HisSl,HistSw,HistPl,HistPw,nrow = 2,top = textGrob("Iris Frequency Histogram",gp=gpar(fontsize=15)))
ggpairs(data = iris[1:4],title = "Iris Correlation Plot")
python:
import pandas as pd
import warnings
import seaborn as sns
import matplotlib.pyplot as plt
#读入数据
iris=pd.read_csv("../input/Iris.csv")
iris.head()
iris["Species"].value_counts()
iris.plot(kind="scatter",x="SepalLengthCm",y="SepalWidthCm")
plt.show()
sns.jointplot(x="SepalLengthCm",y="SepalWidthCm",data=iris,size=5)
sns.FacetGrid(iris, hue="Species", size=5) \ .map(plt.scatter, "SepalLengthCm", "SepalWidthCm") \ .add_legend()
ax=sns.stripplot(x="Species",y="PetalLengthCm",data=iris,jitter=True,edgecolor="gray")
sns.pairplot(iris.drop("Id", axis=1), hue="Species", size=3)
knime:
通过csv reader读入iris文件。然后在analytics下的statistics下选择对应的可视化展现
SPSS statistics:
导入数据