Skip to content

Commit b0ca1e5

Browse files
committed
document title as an object with position attributes
1 parent 4538bfc commit b0ca1e5

File tree

2 files changed

+105
-19
lines changed

2 files changed

+105
-19
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: Styling Names
3-
plot_url: https://codepen.io/plotly/embed/9c5d7e597190632c7a29dcaddaf69236/?height=547&theme-id=15263&default-tab=result
3+
plot_url: https://codepen.io/plotly/embed/LMxqEM/?height=547&theme-id=15263&default-tab=result
44
language: plotly_js
55
suite: labels
66
order: 0
@@ -21,22 +21,35 @@
2121
};
2222
var data = [trace1, trace2];
2323
var layout = {
24-
title: 'Plot Title',
25-
xaxis: {
26-
title: 'x Axis',
27-
titlefont: {
24+
title: {
25+
text:'Plot Title',
26+
font: {
2827
family: 'Courier New, monospace',
29-
size: 18,
30-
color: '#7f7f7f'
31-
}
28+
size: 24
29+
},
30+
xref: 'paper',
31+
x: 0.05,
32+
},
33+
xaxis: {
34+
title: {
35+
text: 'x Axis',
36+
font: {
37+
family: 'Courier New, monospace',
38+
size: 18,
39+
color: '#7f7f7f'
40+
}
41+
},
3242
},
3343
yaxis: {
34-
title: 'y Axis',
35-
titlefont: {
36-
family: 'Courier New, monospace',
37-
size: 18,
38-
color: '#7f7f7f'
44+
title: {
45+
text: 'y Axis',
46+
font: {
47+
family: 'Courier New, monospace',
48+
size: 18,
49+
color: '#7f7f7f'
50+
}
3951
}
4052
}
4153
};
54+
4255
Plotly.newPlot('myDiv', data, layout);

_posts/python/layout/axes/axes.ipynb

+79-6
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,79 @@
341341
"py.iplot(fig, filename='axes-range-manual')"
342342
]
343343
},
344+
{
345+
"cell_type": "markdown",
346+
"metadata": {},
347+
"source": [
348+
"#### Multi-Category Axes"
349+
]
350+
},
351+
{
352+
"cell_type": "code",
353+
"execution_count": 55,
354+
"metadata": {},
355+
"outputs": [
356+
{
357+
"data": {
358+
"text/html": [
359+
"<iframe id=\"igraph\" scrolling=\"no\" style=\"border:none;\" seamless=\"seamless\" src=\"https://buildly.plotly.systems/~michael/34.embed\" height=\"525px\" width=\"100%\"></iframe>"
360+
],
361+
"text/plain": [
362+
"<plotly.tools.PlotlyDisplay object>"
363+
]
364+
},
365+
"execution_count": 55,
366+
"metadata": {},
367+
"output_type": "execute_result"
368+
}
369+
],
370+
"source": [
371+
"import plotly.plotly as py\n",
372+
"import plotly.graph_objs as go\n",
373+
"\n",
374+
"import pandas as pd\n",
375+
"import numpy as np\n",
376+
"\n",
377+
"\n",
378+
"df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/tips.csv')\n",
379+
"pivot_df = df.pivot_table(aggfunc=np.mean, columns=['sex', 'day'], values=['total_bill']).reset_index()\n",
380+
"pivot_df.columns = ['aggregated_value', 'sex', 'day', 'average_value']\n",
381+
"\n",
382+
"\n",
383+
"trace1 = dict(\n",
384+
" x=[\n",
385+
" pivot_df[pivot_df.sex=='Female'].sex,\n",
386+
" pivot_df[pivot_df.sex=='Female'].day\n",
387+
" ],\n",
388+
" y=pivot_df[pivot_df.sex=='Female'].average_value,\n",
389+
" type='bar'\n",
390+
")\n",
391+
"\n",
392+
"trace2 = dict(\n",
393+
" x=[\n",
394+
" pivot_df[pivot_df.sex=='Male'].sex,\n",
395+
" pivot_df[pivot_df.sex=='Male'].day\n",
396+
" ],\n",
397+
" y=pivot_df[pivot_df.sex=='Male'].average_value,\n",
398+
" type='bar'\n",
399+
")\n",
400+
"\n",
401+
"data = [trace1, trace2]\n",
402+
"layout = dict(\n",
403+
" showlegend=False,\n",
404+
" xaxis=dict(\n",
405+
" tickson=\"boundaries\",\n",
406+
" ticklen=15,\n",
407+
" showdividers=True,\n",
408+
" dividercolor='grey',\n",
409+
" dividerwidth=4\n",
410+
" )\n",
411+
")\n",
412+
"\n",
413+
"fig = dict(data=data, layout=layout)\n",
414+
"py.iplot(fig, filename = 'multi-category-axes', validate=False)"
415+
]
416+
},
344417
{
345418
"cell_type": "markdown",
346419
"metadata": {},
@@ -963,23 +1036,23 @@
9631036
"metadata": {
9641037
"anaconda-cloud": {},
9651038
"kernelspec": {
966-
"display_name": "Python 2",
1039+
"display_name": "Python 3",
9671040
"language": "python",
968-
"name": "python2"
1041+
"name": "python3"
9691042
},
9701043
"language_info": {
9711044
"codemirror_mode": {
9721045
"name": "ipython",
973-
"version": 2
1046+
"version": 3
9741047
},
9751048
"file_extension": ".py",
9761049
"mimetype": "text/x-python",
9771050
"name": "python",
9781051
"nbconvert_exporter": "python",
979-
"pygments_lexer": "ipython2",
980-
"version": "2.7.15rc1"
1052+
"pygments_lexer": "ipython3",
1053+
"version": "3.6.5"
9811054
}
9821055
},
9831056
"nbformat": 4,
984-
"nbformat_minor": 1
1057+
"nbformat_minor": 2
9851058
}

0 commit comments

Comments
 (0)