Skip to content

Commit af3d3ef

Browse files
committed
Merge pull request #4 from plotly/bar_charts_with_different_examples_13388529493274
bar marker array example
2 parents 66f145c + 4bd2503 commit af3d3ef

File tree

26 files changed

+1040
-654
lines changed

26 files changed

+1040
-654
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Plotly
2+
3+
{% if not username %}# Fill in with your personal username and API key
4+
# or, use this public demo account
5+
{% endif %}Plotly.signin({% if username %}"{{username}}"{% else %}"Julia-Demo-Account"{% endif %}, {% if api_key %}"{{api_key}}"{% else %}"hvkrsbg3uj"{% endif %})
6+
7+
data = [
8+
[
9+
"x" => [1, 2, 3, 4],
10+
"y" => [5, 4, -3, 2],
11+
"marker" => ["color" => ["#447adb", "#447adb", "#db5a44", "#447adb"]],
12+
"type" => "bar"
13+
]
14+
]
15+
16+
response = Plotly.plot([data], ["filename" => "bar-marker-array", "fileopt" => "overwrite"])
17+
plot_url = response["url"]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{% if not username %}% Fill in with your personal username and API key
2+
% or, use this public demo account
3+
{% endif %}signin({% if username %}'{{username}}'{% else %}'MATLAB-Demo-Account'{% endif %}, {% if api_key %}'{{api_key}}'{% else %}'p42phiifti'{% endif %})
4+
5+
data = {...
6+
struct(...
7+
'x', [1, 2, 3, 4], ...
8+
'y', [5, 4, -3, 2], ...
9+
'marker', struct('color', { {'#447adb', '#447adb', '#db5a44', '#447adb'} }), ...
10+
'type', 'bar')...
11+
};
12+
13+
response = plotly(data, struct('filename', 'bar-marker-array', 'fileopt', 'overwrite'));
14+
plot_url = response.url
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{% if not username %}// Fill in with your personal username and API key
2+
// or, use this public demo account
3+
{% endif %}var plotly = require('plotly')({% if username %}'{{username}}'{% else %}'Node.js-Demo-Account'{% endif %},{% if api_key %}'{{api_key}}'{% else %}'dvlqkmw0zm'{% endif %});
4+
5+
var data = [
6+
{
7+
x: [1, 2, 3, 4],
8+
y: [5, 4, -3, 2],
9+
marker: {color: ["#447adb", "#447adb", "#db5a44", "#447adb"]},
10+
type: "bar"
11+
}
12+
];
13+
14+
var graph_options = {filename: "bar-marker-array", fileopt: "overwrite"}
15+
plotly.plot(data, graph_options, function (err, msg) {
16+
console.log(msg);
17+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import plotly.plotly as py
2+
from plotly.graph_objs import *
3+
4+
{% if not username %}# Fill in with your personal username and API key
5+
# or, use this public demo account
6+
{% endif %}py.sign_in({% if username %}"{{username}}"{% else %}'Python-Demo-Account'{% endif %}, {% if api_key %}"{{api_key}}"{% else %}'gwt101uhh0'{% endif %})
7+
8+
data = Data([
9+
Bar(
10+
x=[1, 2, 3, 4],
11+
y=[5, 4, -3, 2],
12+
marker=Marker(
13+
color=['#447adb', '#447adb', '#db5a44', '#447adb']
14+
)
15+
)
16+
])
17+
18+
plot_url = py.plot(data, filename='bar-marker-array')
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
library(plotly)
2+
3+
{% if not username %}# Fill in with your personal username and API key
4+
# or, use this public demo account
5+
{% endif %}p <- plotly(username={% if username %}"{{username}}"{% else %}'R-Demo-Account'{% endif %}, key={% if api_key %}"{{api_key}}"{% else %}'yu680v5eii'{% endif %})
6+
7+
data <- list(
8+
list(
9+
x = c(1, 2, 3, 4),
10+
y = c(5, 4, -3, 2),
11+
marker = list(color = c("#447adb", "#447adb", "#db5a44", "#447adb")),
12+
type = "bar"
13+
)
14+
)
15+
16+
response <- p$plotly(data, kwargs=list(filename="bar-marker-array", fileopt="overwrite"))
17+
url <- response$url
18+
filename <- response$filename
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Plotly
2+
3+
using Plotly
4+
Plotly.signin("TestBot", "r1neazxo9w")
5+
6+
data = [
7+
[
8+
"x" => [1, 2, 3, 4],
9+
"y" => [5, 4, -3, 2],
10+
"marker" => ["color" => ["#447adb", "#447adb", "#db5a44", "#447adb"]],
11+
"type" => "bar"
12+
]
13+
]
14+
15+
response = Plotly.plot([data], ["filename" => "bar-marker-array", "fileopt" => "overwrite", "auto_open" => "false"])
16+
plot_url = response["url"]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
signin('TestBot', 'r1neazxo9w')
2+
3+
data = {...
4+
struct(...
5+
'x', [1, 2, 3, 4], ...
6+
'y', [5, 4, -3, 2], ...
7+
'marker', struct('color', { {'#447adb', '#447adb', '#db5a44', '#447adb'} }), ...
8+
'type', 'bar')...
9+
};
10+
11+
response = plotly(data, struct('filename', 'bar-marker-array', 'fileopt', 'overwrite', 'auto_open', 'false'));
12+
plot_url = response.url
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var plotly = require('plotly')('TestBot', 'r1neazxo9w')
2+
3+
var data = [
4+
{
5+
x: [1, 2, 3, 4],
6+
y: [5, 4, -3, 2],
7+
marker: {color: ["#447adb", "#447adb", "#db5a44", "#447adb"]},
8+
type: "bar"
9+
}
10+
];
11+
12+
var graph_options = {filename: "bar-marker-array", fileopt: "overwrite", auto_open: "false"}
13+
plotly.plot(data, graph_options, function (err, msg) {
14+
console.log(msg);
15+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import plotly.plotly as py
2+
from plotly.graph_objs import *
3+
4+
py.sign_in('TestBot', 'r1neazxo9w')
5+
6+
data = Data([
7+
Bar(
8+
x=[1, 2, 3, 4],
9+
y=[5, 4, -3, 2],
10+
marker=Marker(
11+
color=['#447adb', '#447adb', '#db5a44', '#447adb']
12+
)
13+
)
14+
])
15+
16+
plot_url = py.plot(data, filename='bar-marker-array', auto_open=False)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
library(plotly)
2+
3+
p <- plotly(username='TestBot', key='r1neazxo9w')
4+
5+
data <- list(
6+
list(
7+
x = c(1, 2, 3, 4),
8+
y = c(5, 4, -3, 2),
9+
marker = list(color = c("#447adb", "#447adb", "#db5a44", "#447adb")),
10+
type = "bar"
11+
)
12+
)
13+
14+
response <- p$plotly(data, kwargs=list(filename="bar-marker-array", fileopt="overwrite", auto_open="FALSE"))
15+
url <- response$url
16+
filename <- response$filename
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"languages": [
3+
"python",
4+
"nodejs",
5+
"r",
6+
"matlab",
7+
"julia"
8+
],
9+
"name": "Customizing Individual Bar Colors"
10+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"data": [
3+
{
4+
"x": [
5+
1,
6+
2,
7+
3,
8+
4
9+
],
10+
"y": [
11+
5,
12+
4,
13+
-3,
14+
2
15+
],
16+
"marker": {
17+
"color": [
18+
"#447adb",
19+
"#447adb",
20+
"#db5a44",
21+
"#447adb"
22+
]
23+
},
24+
"type": "bar"
25+
}
26+
]
27+
}

ids.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"axes-reversed",
2727
"axes-ticks",
2828
"bar-line",
29+
"bar-marker-array",
2930
"basic-area",
3031
"basic-bar",
3132
"basic-box-plot",
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Plotly
2+
3+
{% if not username %}# Fill in with your personal username and API key
4+
# or, use this public demo account
5+
{% endif %}Plotly.signin({% if username %}"{{username}}"{% else %}"Julia-Demo-Account"{% endif %}, {% if api_key %}"{{api_key}}"{% else %}"hvkrsbg3uj"{% endif %})
6+
7+
data = [
8+
[
9+
"x" =&gt; [1, 2, 3, 4],
10+
"y" =&gt; [5, 4, -3, 2],
11+
"marker" =&gt; ["color" =&gt; ["#447adb", "#447adb", "#db5a44", "#447adb"]],
12+
"type" =&gt; "bar"
13+
]
14+
]
15+
16+
response = Plotly.plot([data], ["filename" =&gt; "bar-marker-array", "fileopt" =&gt; "overwrite"])
17+
plot_url = response["url"]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{% if not username %}% Fill in with your personal username and API key
2+
% or, use this public demo account
3+
{% endif %}signin({% if username %}'{{username}}'{% else %}'MATLAB-Demo-Account'{% endif %}, {% if api_key %}'{{api_key}}'{% else %}'p42phiifti'{% endif %})
4+
5+
data = {...
6+
struct(...
7+
'x', [1, 2, 3, 4], ...
8+
'y', [5, 4, -3, 2], ...
9+
'marker', struct('color', { {'#447adb', '#447adb', '#db5a44', '#447adb'} }), ...
10+
'type', 'bar')...
11+
};
12+
13+
response = plotly(data, struct('filename', 'bar-marker-array', 'fileopt', 'overwrite'));
14+
plot_url = response.url
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{% if not username %}// Fill in with your personal username and API key
2+
// or, use this public demo account
3+
{% endif %}var plotly = require('plotly')({% if username %}'{{username}}'{% else %}'Node.js-Demo-Account'{% endif %},{% if api_key %}'{{api_key}}'{% else %}'dvlqkmw0zm'{% endif %});
4+
5+
var data = [
6+
{
7+
x: [1, 2, 3, 4],
8+
y: [5, 4, -3, 2],
9+
marker: {color: ["#447adb", "#447adb", "#db5a44", "#447adb"]},
10+
type: "bar"
11+
}
12+
];
13+
14+
var graph_options = {filename: "bar-marker-array", fileopt: "overwrite"}
15+
plotly.plot(data, graph_options, function (err, msg) {
16+
console.log(msg);
17+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import plotly.plotly as py
2+
from plotly.graph_objs import *
3+
4+
{% if not username %}# Fill in with your personal username and API key
5+
# or, use this public demo account
6+
{% endif %}py.sign_in({% if username %}"{{username}}"{% else %}'Python-Demo-Account'{% endif %}, {% if api_key %}"{{api_key}}"{% else %}'gwt101uhh0'{% endif %})
7+
8+
data = Data([
9+
Bar(
10+
x=[1, 2, 3, 4],
11+
y=[5, 4, -3, 2],
12+
marker=Marker(
13+
color=['#447adb', '#447adb', '#db5a44', '#447adb']
14+
)
15+
)
16+
])
17+
18+
plot_url = py.plot(data, filename='bar-marker-array')
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
library(plotly)
2+
3+
{% if not username %}# Fill in with your personal username and API key
4+
# or, use this public demo account
5+
{% endif %}p &lt;- plotly(username={% if username %}"{{username}}"{% else %}'R-Demo-Account'{% endif %}, key={% if api_key %}"{{api_key}}"{% else %}'yu680v5eii'{% endif %})
6+
7+
data &lt;- list(
8+
list(
9+
x = c(1, 2, 3, 4),
10+
y = c(5, 4, -3, 2),
11+
marker = list(color = c("#447adb", "#447adb", "#db5a44", "#447adb")),
12+
type = "bar"
13+
)
14+
)
15+
16+
response &lt;- p$plotly(data, kwargs=list(filename="bar-marker-array", fileopt="overwrite"))
17+
url &lt;- response$url
18+
filename &lt;- response$filename

published/api-docs/references/julia.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,21 @@
118118
],
119119
"type": "model",
120120
"id": "style-bar"
121+
},
122+
{
123+
"code": "chart-types/bar/bar-marker-array/julia/code.txt",
124+
"name": "Customizing Individual Bar Colors",
125+
"parent": "bar",
126+
"url": "https://plot.ly/~PlotBot/177",
127+
"languages": [
128+
"python",
129+
"nodejs",
130+
"r",
131+
"matlab",
132+
"julia"
133+
],
134+
"type": "model",
135+
"id": "bar-marker-array"
121136
}
122137
],
123138
"description": "How to make a bar chart in {language}. {num_examples} examples of grouped, stacked, overlaid, and colored bar charts.",

0 commit comments

Comments
 (0)