data-visualization

using Matplotlib how to highlight one point in the final plot

女生的网名这么多〃 提交于 2020-01-12 13:01:09
问题 Suppose, I have x = [1,2,3,4,5,6] and the corresponding y = [3,4,5,6,7,8] . I want the first pair (1,3) to be in a different color or shape. How can this be done using python? 回答1: One of the simplest possible answers. import matplotlib.pyplot as plt x = [1,2,3,4,5,6] y = [3,4,5,6,7,8] plt.plot(x[1:], y[1:], 'ro') plt.plot(x[0], y[0], 'g*') plt.show() 来源: https://stackoverflow.com/questions/41489543/using-matplotlib-how-to-highlight-one-point-in-the-final-plot

Heatmap with circles indicating size of population

梦想的初衷 提交于 2020-01-11 09:34:07
问题 Hi I would like to produce a heatmap in Python, similar to the one shown, where the size of the circle indicates the size of the sample in that cell. I looked in seaborn's gallery and couldn't find anything, and I don't think I can do this with matplotlib. 回答1: It's the inverse. While matplotlib can do pretty much everything, seaborn only provides a small subset of options. So using matplotlib, you can plot a PatchCollection of circles as shown below. Note: You could equally use a scatter

Generating spatial heat map via ggmap in R based on a value

♀尐吖头ヾ 提交于 2020-01-10 20:11:33
问题 I'd like to generate a choropleth map using the following data points: Longitude Latitude Price Here is the dataset - https://www.dropbox.com/s/0s05cl34bko7ggm/sample_data.csv?dl=0. I would like the map to show the areas where the price is higher and the where price is lower. It should most probably look like this (sample image): Here is my code: library(ggmap) map <- get_map(location = "austin", zoom = 9) data <- read.csv(file.choose(), stringsAsFactors = FALSE) data$average_rate_per_night <

Legend is apears in the wrong place in the page (R): not fully shown

我怕爱的太早我们不能终老 提交于 2020-01-07 09:51:46
问题 I have added the following command to the plot in R: df<- read.table("filename.csv", header=TRUE, sep=",", stringsAsFactors=FALSE) tdf=as.data.frame(df[2:ncol(df)]) # draw the plot bb<- barplot(as.matrix(tdf), beside=T , col=colours,border="black", ylim=c(0,100), ylab="Percentage (%)",xlab="Methods)") y<-as.matrix(tdf) text(bb,y+2,labels=as.character(y),pos =1,offset=3,cex = 0.6, col = "black") legend("topleft", c("M1","M2","M3","M4","M5", "M6"), cex=0.6,inset=c(1,0),xpd=TRUE, fill=colours)

Legend is apears in the wrong place in the page (R): not fully shown

Deadly 提交于 2020-01-07 09:51:10
问题 I have added the following command to the plot in R: df<- read.table("filename.csv", header=TRUE, sep=",", stringsAsFactors=FALSE) tdf=as.data.frame(df[2:ncol(df)]) # draw the plot bb<- barplot(as.matrix(tdf), beside=T , col=colours,border="black", ylim=c(0,100), ylab="Percentage (%)",xlab="Methods)") y<-as.matrix(tdf) text(bb,y+2,labels=as.character(y),pos =1,offset=3,cex = 0.6, col = "black") legend("topleft", c("M1","M2","M3","M4","M5", "M6"), cex=0.6,inset=c(1,0),xpd=TRUE, fill=colours)

Higher ROC-AUC and F-1 scores but poor looking ROC-curves

China☆狼群 提交于 2020-01-06 05:39:05
问题 I recreated a new Ensemble method that does Voting manually between my three classifiers. (Courtesty of Daniel who helped me make the function from here: Improving the prediction score by use of confidence level of classifiers on instances). The purpose of this manual voting was to accept the answers for each instance for the most confident classifier. Below is the code with their accuracy scores: # parameters for random forest rfclf_params = { 'n_estimators': 500, 'bootstrap': True, 'class

Python: Best way to visualize dict of dicts

可紊 提交于 2020-01-06 04:45:06
问题 I want to visualize the following dict of dicts players_info = {'Afghanistan': {'Asghar Stanikzai': 809.0, 'Mohammad Nabi': 851.0, 'Mohammad Shahzad': 1713.0, 'Najibullah Zadran': 643.0, 'Samiullah Shenwari': 774.0}, 'Australia': {'AJ Finch': 1082.0, 'CL White': 988.0, 'DA Warner': 1691.0, 'GJ Maxwell': 822.0, 'SR Watson': 1465.0}, 'England': {'AD Hales': 1340.0, 'EJG Morgan': 1577.0, 'JC Buttler': 985.0, 'KP Pietersen': 1176.0, 'LJ Wright': 759.0}} Currently I am using the following way but

Merge two different plots: one in the X-axis and the other in the Y-axis

不羁的心 提交于 2020-01-06 01:28:12
问题 I have the represented independently these two plots using R: #PLOT 1 x<-250:2500 #Hsap. Northern European a<-dnorm(x,1489,167) #Hsap. South African b<-dnorm(x,1472,142) plot(x,a, type="l", lwd=3, ylim=c(0,1.2*max(a,b,c)), ylab="Probability Density", xlab="Microns") lines(x,b, type="l", lwd=3, col="Red") PLOT 2 #CUSPAL ENAMEL FORMATION TIME x<-0:800 #Hsap. Northern European a<-dnorm(x,447,37) #Hsap. South African b<-dnorm(x,444,33) plot(x,a, type="l", lwd=3, ylim=c(0,1.2*max(a,b,c)), ylab=

displaying stat_summary accurately on violin plots

独自空忆成欢 提交于 2020-01-05 09:28:25
问题 I just started using ggplot2 on R and have a violin plot question. I have a data set that can be accessed here: data. The data comes from a study of making estimations. The variables of interest are the question.no (questions), condition, estimate.no (tr.est1 or tr.est2) and estimate. The code below makes the plot look almost the way I want it to look at least for one question, yet the median dots generated by stat_summary() are displayed in between the "violins." v.data<-read.csv("data.csv")

displaying stat_summary accurately on violin plots

爷,独闯天下 提交于 2020-01-05 09:28:03
问题 I just started using ggplot2 on R and have a violin plot question. I have a data set that can be accessed here: data. The data comes from a study of making estimations. The variables of interest are the question.no (questions), condition, estimate.no (tr.est1 or tr.est2) and estimate. The code below makes the plot look almost the way I want it to look at least for one question, yet the median dots generated by stat_summary() are displayed in between the "violins." v.data<-read.csv("data.csv")