I'd like to draw a scatterplot using Python's matplotlib/seaborn, but the Roman alphabet name is Dataframe's index, and I'd like to plot it as a dot.
In the case of R, for example, iris data,
>plot(iris[,1], iris[,3], type="n")
>text(iris[,1],iris[,3])
If so, it will be printed, but what should I do in the case of matplotlib?
I looked it up, but I couldn't get to the answer because matplotlib doesn't have an option.
Now
plt.scatter(x,y)
The scatterplot output plotted in is made of matplotlib.
Thank you for your cooperation.
****Additional ****
Sorry for the insufficient explanation.
I would like to write a code in which each individual becomes their name (for example, Hokkaido data is called hokkaido and Tokyo data is called Tokyo) instead of just a circle or a bump.The image is from https://www1.doshisha.ac.jp/~mjin/R/06.html page 12 or 13.
Currently, I only write with matplotlib, but I don't care if it's seaborn or not.
I will upload the code tomorrow.
****Additional ****
Code for R, created with reference to http://hnsn1202.hateblo.jp/entry/2013/02/10/041045.
The first row is the county name, the second row is the income, and the third row is the population density.
library(data.table)
new<-fread("new.csv", header=TRUE)
plot(new[,2], new[,3], type="n")
text(new[,2], new[,3], new.label)
colnames(new)<-c("pre", "come", "mitsudo")
library (maptools)
new<-as.data.frame(new)
plot(new[,2], new[,3], type="n")
pointLabel(x=new[,2], y=new[,3], labels=new$pre)
Do you mean that you don't understand the method of the scatterplot?
Seaborn can draw scatterplots using a method called jointplot
.I understood your intention to write a scatterplot, but I don't know anything more, so I think you'll get a better answer if you share the code.
For marker
, you can specify what is mathtext
(although this may not be the case).
import matplotlib.pyplot as plt
x = [1, 2, 3, 4, 5, 6]
y = [2**x for x in x ]
plt.scatter(x,y,marker="$Tokyo$",s=20**2)
plt.show()
Or, regardless of scatter
, you may use methods such as text
, annotate
, plot
.
© 2024 OneMinuteCode. All rights reserved.