|
341 | 341 | "py.iplot(fig, filename='axes-range-manual')"
|
342 | 342 | ]
|
343 | 343 | },
|
| 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 | + }, |
344 | 417 | {
|
345 | 418 | "cell_type": "markdown",
|
346 | 419 | "metadata": {},
|
|
963 | 1036 | "metadata": {
|
964 | 1037 | "anaconda-cloud": {},
|
965 | 1038 | "kernelspec": {
|
966 |
| - "display_name": "Python 2", |
| 1039 | + "display_name": "Python 3", |
967 | 1040 | "language": "python",
|
968 |
| - "name": "python2" |
| 1041 | + "name": "python3" |
969 | 1042 | },
|
970 | 1043 | "language_info": {
|
971 | 1044 | "codemirror_mode": {
|
972 | 1045 | "name": "ipython",
|
973 |
| - "version": 2 |
| 1046 | + "version": 3 |
974 | 1047 | },
|
975 | 1048 | "file_extension": ".py",
|
976 | 1049 | "mimetype": "text/x-python",
|
977 | 1050 | "name": "python",
|
978 | 1051 | "nbconvert_exporter": "python",
|
979 |
| - "pygments_lexer": "ipython2", |
980 |
| - "version": "2.7.15rc1" |
| 1052 | + "pygments_lexer": "ipython3", |
| 1053 | + "version": "3.6.5" |
981 | 1054 | }
|
982 | 1055 | },
|
983 | 1056 | "nbformat": 4,
|
984 |
| - "nbformat_minor": 1 |
| 1057 | + "nbformat_minor": 2 |
985 | 1058 | }
|
0 commit comments