labels

Adding text labels to ggplot2 scatterplot

五迷三道 提交于 2019-12-31 12:12:18
问题 Is there a good way easy way to add text labels to the circles on the graph? I haven't able to do it using the directlabels package because I get the error: Error in direct.label.ggplot(p, "first.qp") : Need colour aesthetic to infer default direct labels." Here is the graph: And here is the code that I've been using: library(ggplot2) library(directlabels) #my data set: oc <- read.csv("http://www.columbia.edu/~mad2200/oc.csv") oc$percent_women <- oc$W_employment/(oc$M_employment+oc$W

Adding text labels to ggplot2 scatterplot

泪湿孤枕 提交于 2019-12-31 12:12:09
问题 Is there a good way easy way to add text labels to the circles on the graph? I haven't able to do it using the directlabels package because I get the error: Error in direct.label.ggplot(p, "first.qp") : Need colour aesthetic to infer default direct labels." Here is the graph: And here is the code that I've been using: library(ggplot2) library(directlabels) #my data set: oc <- read.csv("http://www.columbia.edu/~mad2200/oc.csv") oc$percent_women <- oc$W_employment/(oc$M_employment+oc$W

How to change panel labels and x-axis sublabels in a lattice bwplot

五迷三道 提交于 2019-12-30 17:57:10
问题 I'm 2 weeks into using RStudio (MacOS) so please forgive me if I'm overlooking an obvious function that would solve my problem. As a project, I am attempting to reproduce a box plot graph with 4 plots representing Net Benefit, given disease type -- "non-severe"(0) or "severe"(1) -- as an x-axis label, and given treatment -- "talk therapy"(0) or "drug therapy"(1) -- as an x-axis sub-label. Here is my script so far: tx <- c(0,0,0,0,1,1,1,1) dztype <- c(1,0,1,0,0,0,1,1) NBwtp1000 <- c(-5500,

R: Assign variable labels of data frame columns

若如初见. 提交于 2019-12-29 14:15:11
问题 I am struggling with variable labels of data.frame columns. Say I have the following data frame (part of much larger data frame): data <- data.frame(age = c(21, 30, 25, 41, 29, 33), sex = factor(c(1, 2, 1, 2, 1, 2), labels = c("Female", "Male"))) # I also have a named vector with the variable labels for this data frame: var.labels <- c(age = "Age in Years", sex = "Sex of the participant") I want to assign the variable labels in var.labels to the columns in the data frame data using the

matplotlib prune tick labels

主宰稳场 提交于 2019-12-29 07:44:15
问题 I am using GridSpec to plot two plots one below the other without a gap in between with gs = gridspec.GridSpec(3, 1) gs.update(hspace=0., wspace=0.) ax1 = plt.subplot(gs[0:2, 0]) ax2 = plt.subplot(gs[2, 0], sharex=ax1) which works fine. However, I want to get rid of each subplot's top and bottom tick label. For that I use nbins = len(ax1.get_yticklabels()) ax1.yaxis.set_major_locator(MaxNLocator(nbins=nbins, prune='both')) nbins = len(ax2.get_yticklabels()) ax2.yaxis.set_major_locator

Swift: expected declaration error setting “Label” to a string variable

一曲冷凌霜 提交于 2019-12-29 07:37:34
问题 I am managing different languages, in a small single pane app, using a different string array for each comment, indexed by an integer variable "userLang", then setting label.text = array[index]. The basic code is: import UIKit class ViewController: UIViewController { var userLang = 0 var arrayOne = ["hi", "hola"] var arrayTwo = ["Bye", "Adios"] @IBOutlet weak var msgArrayOne: UILabel! @IBOutlet weak var msgArrayTwo: UILabel! msgArrayOne.text = arrayOne[userLang] //Error here: !Expected

using labels in java without “loops”

怎甘沉沦 提交于 2019-12-28 01:27:38
问题 I always thought that the labels must be used only with loops but it seems not. Giving such code: public class LabelTest { public static void main(String[] args) { label1: System.out.println(""); label2: LabelTest t = new LabelTest(); } } When compiled line labeled "label1" compiles but the code at "label2" gives errors. Why's that? And why would I want to label statements which are not "loops"? 回答1: You get an error because a label cannot be applied to variable declarations, that's just how

How to center stacked percent barchart labels

佐手、 提交于 2019-12-27 11:40:07
问题 I am trying to plot nice stacked percent barchart using ggplot2 . I've read some material and almost manage to plot, what I want. Also, I enclose the material, it might be useful in one place: How do I label a stacked bar chart in ggplot2 without creating a summary data frame? Create stacked barplot where each stack is scaled to sum to 100% R stacked percentage bar plot with percentage of binary factor and labels (with ggplot) My problem is that I can't place labels where I want - in the

How to center stacked percent barchart labels

北慕城南 提交于 2019-12-27 11:40:06
问题 I am trying to plot nice stacked percent barchart using ggplot2 . I've read some material and almost manage to plot, what I want. Also, I enclose the material, it might be useful in one place: How do I label a stacked bar chart in ggplot2 without creating a summary data frame? Create stacked barplot where each stack is scaled to sum to 100% R stacked percentage bar plot with percentage of binary factor and labels (with ggplot) My problem is that I can't place labels where I want - in the

Python - Subtract a number of samples from a given in a dictionary structure

你说的曾经没有我的故事 提交于 2019-12-26 01:27:55
问题 I have a dict structure with length 5. The dict structure is called "mat_contents". The information is located in "traindata" and their respective labels in "trainlabels". I want to extract a given number of samples from a given label value. For instance, 60 samples (out of 80) from "traindata" with label "trainlabels" equal 1. I have seen some examples in here but they are different from my request. Assuming this as an example of Input traindata trainlabels a 1 b 2 c 2 d 1 e 1 f 2 The result