8000 Adding the page for Plotting Data from CSV (#85) · aldoclemente/plotly.r-docs@f39fbbe · GitHub
[go: up one dir, main page]

Skip to content

Commit f39fbbe

Browse files
kvdesaiKalpit DesaiHammadTheOne
authored
Adding the page for Plotting Data from CSV (plotly#85)
* Adding the page for Plotting Data from CSV * Updating tags Co-authored-by: Kalpit Desai <kalpit@datakalp.com> Co-authored-by: Hammad Khan <hammadtheone@gmail.com>
1 parent a460f07 commit f39fbbe

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

r/plot-data-from-csv.Rmd

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
description: How to create charts from csv files with Plotly and Python
3+
display_as: advanced_opt
4+
language: r
5+
layout: base
6+
name: Plot CSV Data
7+
order: 1
8+
output:
9+
html_document:
10+
keep_md: true
11+
page_type: example_index
12+
permalink: r/plot-data-from-csv/
13+
thumbnail: thumbnail/csv.jpg
14+
---
15+
```{r, echo = FALSE, message=FALSE}
16+
knitr::opts_chunk$set(message = FALSE, warning = FALSE)
17+
```
18+
19+
CSV or comma-delimited-values is a very popular format for storing structured data. In this tutorial, we will see how to plot beautiful graphs using csv data. We will learn how to import csv data from an external source (a URL), and plot it using Plotly.
20+
21+
First we import the data and look at it.
22+
23+
```{r}
24+
data <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_apple_stock.csv')
25+
head(data)
26+
```
27+
28+
### Plot from CSV with Plotly
29+
30+
```{r}
31+
library(plotly)
32+
data <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_apple_stock.csv')
33+
fig <- plot_ly(x = as.Date(data$AAPL_x), y = data$AAPL_y, type = 'scatter', mode = 'lines'
34+
, name = 'Share Prices (in USD)')%>%
35+
layout(title = 'Apple Share Prices over time (2014)',
36+
plot_bgcolor='#e5ecf6',
37+
xaxis = list(
38+
title = 'AAPL_x',
39+
zerolinecolor = '#ffff',
40+
zerolinewidth = 2,
41+
gridcolor = 'ffff'),
42+
yaxis = list(
43+
title = 'AAPL_y',
44+
zerolinecolor = '#ffff',
45+
zerolinewidth = 2,
46+
gridcolor = 'ffff'),
47+
showlegend = TRUE, width = 1100)
48+
fig
49+
```
50+
51+
#### Reference
52+
53+
See https://plotly.com/r/getting-started for more information about Plotly's R API!

0 commit comments

Comments
 (0)
0