Here is what I learned from the Dataviz Challenge #2

Here is what I learned from taking part in the  Dataviz Challenge #2

 1. Customizing colors. I learned how to  use a color picker to identify colors being used in the example  chart and apply in R.  Resource: R color picker index

2. Placing the data labels in the bars . Resource–How to do it

3. I learned how to use R studio to Markdown the R code into html and post on this blog.

Challenges–I have not figured out how to change the size and color of the axes labels. The code is below.
.knitr.inline { background-color: #f7f7f7; border:solid 1px #B0B0B0; } .error { font-weight: bold; color: #FF0000; }, .warning { font-weight: bold; } .message { font-style: italic; } .source, .output, .warning, .error, .message { padding: 0em 1em; border:solid 1px #F7F7F7; } .source { background-color: #f7f7f7; } .rimage.left { text-align: left; } .rimage.right { text-align: right; } .rimage.center { text-align: center; } .source { color: #333333; } .background { color: #F7F7F7; } .number { color: #000000; } .functioncall { color: #800054; font-weight: bolder; } .string { color: #9999FF; } .keyword { font-weight: bolder; color: black; } .argument { color: #B04005; } .comment { color: #2E9957; } .roxygencomment { color: #707AB3; } .formalargs { color: #B04005; } .eqformalargs { color: #B04005; } .assignement { font-weight: bolder; color: #000000; } .package { color: #96B525; } .slot { font-style: italic; } .symbol { color: #000000; } .prompt { color: #333333; } Dataviz Challenge # 2

# Establish data
Youth <- c(202, 278, 410, 416, 450, 470)
# Displays the data
print(Youth)
## [1] 202 278 410 416 450 470
#Bar Graph
bp<-barplot(Youth, main="Number of Youth Served By Year", axes=FALSE,
#Establishes Color Scheme and it was easier just to add the hex number of the color
col=c("#92C5C6","#92C5C6","#92C5C6","#92C5C6","#92C5C6","#31737F"),
#Estblishes Axes Labels
names.arg = c ("'07","'08","'09","'10","'11","'12"))
#Adds back horizontal line and in the color gray
abline(h=0, col="gray")
#Tells where on the grid to place the data label, color, and size
text(.70,191, "202", col="White", cex=1.5)
text(1.90,265, "278", col="White", cex=1.5)
text(3.1,398, "410", col="White",cex=1.5)
text(4.3,405, "416", col="White",cex=1.5)
text(5.5,440, "450", col="White",cex=1.5)
text(6.7,460, "470", col="White",cex=1.5)


Here is the final product!

Advertisements
This entry was posted in barplot, Dataviz Challenge #2, R. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s