Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b9667cf
Initial commit
lukelbd Dec 19, 2019
83ef32c
Merge branch 'master' into rc-cleanup-fixes
lukelbd Jan 6, 2020
e464a99
Move default props from .proplotrc --> rctools.py
lukelbd Jan 6, 2020
e760807
Improve rc_configurator getitem/setitem, add helper func
lukelbd Jan 6, 2020
d6b6020
Update get(), fill(), category(); add dict() and iterator methods
lukelbd Jan 6, 2020
a82dd68
Fix rc_configurator.context() bug
lukelbd Jan 6, 2020
dea6d94
Improve iter, contains, and string repr methods
lukelbd Jan 6, 2020
44a4bc9
Improve _loc_translate + _get_title_props, related cleanup
lukelbd Jan 7, 2020
424bc67
Remove Axes.context, update rc lookups, related cleanup
lukelbd Jan 7, 2020
8e7655e
Add x/ylinewidth, x/ygridcolor XYAxes.format kwargs
lukelbd Jan 7, 2020
25f7bd8
Fix rc lookups in other files
lukelbd Jan 7, 2020
77e406a
Remove Axes.context, add documented Axes.number prop
lukelbd Jan 7, 2020
61a45d4
Update changelog and index
lukelbd Jan 7, 2020
93c8aa5
Cleaner install instructions
lukelbd Jan 7, 2020
da123eb
Remove rc._init reference
lukelbd Jan 7, 2020
5b45522
Fix bug/conflict between ipython_* funcs and rc.__init__
lukelbd Jan 7, 2020
1bf78ce
Remove _getitem_mode assignment
lukelbd Jan 7, 2020
3c44865
Add _get_space function, simplify _panel_kwargs function
lukelbd Jan 7, 2020
3fb9a52
Rename _panel_kwargs --> _get_panelargs
lukelbd Jan 7, 2020
dba9f70
Use _get_space; remove refs to subplots.ylabspace, etc.
lukelbd Jan 7, 2020
fdfe042
Update default font sizes
lukelbd Jan 7, 2020
3218c2a
Change refs from panelspace --> panelpad
lukelbd Jan 7, 2020
1ab92ca
Remove subplots.ylabspace, etc. from configuration docs
lukelbd Jan 7, 2020
16ae44f
Fix _loc_translate bug
lukelbd Jan 7, 2020
6629efb
Remove panel_kw from colorbar/legend_wrapper
lukelbd Jan 7, 2020
ef33694
Update changelog
lukelbd Jan 7, 2020
20b9f5b
No longer change figure.dpi
lukelbd Jan 7, 2020
db78bc0
Fix rc.category bug, minor subplots bugs
lukelbd Jan 7, 2020
c57c7b0
Prefer closing brackets on new lines
lukelbd Jan 7, 2020
578aa8b
Better install instructions
lukelbd Jan 7, 2020
7acffb6
Update changelog
lukelbd Jan 7, 2020
8da19f5
Remove outdated cache=False ref, remove debug statement
lukelbd Jan 7, 2020
3ca9a02
Minor BasemapAxes bugfix
lukelbd Jan 7, 2020
22af8f9
Notebook examples formatting improvements
lukelbd Jan 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Notebook examples formatting improvements
  • Loading branch information
lukelbd committed Jan 7, 2020
commit 22af8f91de4424e3bcca25f974c44697653dfc6b
157 changes: 105 additions & 52 deletions docs/1dplots.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"import xarray as xr\n",
"import numpy as np\n",
"import pandas as pd\n",
"\n",
"# DataArray\n",
"state = np.random.RandomState(51423)\n",
"data = np.sin(np.linspace(0, 2*np.pi, 20))[:, None] \\\n",
Expand All @@ -66,6 +67,7 @@
" 'x': xr.DataArray(np.linspace(0, 1, 20), dims=('x',), attrs={'long_name': 'distance', 'units': 'km'}),\n",
" 'cat': xr.DataArray(np.arange(0, 80, 10), dims=('cat',), attrs={'long_name': 'parameter', 'units': 'K'})\n",
"}, name='position series')\n",
"\n",
"# DataFrame\n",
"ts = pd.date_range('1/1/2000', periods=20)\n",
"data = (np.cos(np.linspace(0, 2*np.pi, 20))**4)[:, None] + state.rand(20, 5)**2\n",
Expand All @@ -84,9 +86,11 @@
"import proplot as plot\n",
"f, axs = plot.subplots(ncols=2, axwidth=2.2, share=0)\n",
"axs.format(suptitle='Automatic subplot formatting')\n",
"\n",
"# Plot DataArray\n",
"cycle = plot.Cycle(plot.shade('light blue', 0.4), fade=90, space='hpl')\n",
"axs[0].plot(da, cycle=cycle, lw=3, colorbar='ul', colorbar_kw={'locator': 20})\n",
"\n",
"# Plot Dataframe\n",
"cycle = plot.Cycle(plot.shade('jade', 0.4), fade=90, space='hpl')\n",
"axs[1].plot(df, cycle=cycle, lw=3, legend='uc')"
Expand Down Expand Up @@ -122,28 +126,36 @@
"state = np.random.RandomState(51423)\n",
"data = state.rand(20, 8).cumsum(axis=0).cumsum(axis=1)[:, ::-1] \\\n",
" + 20*state.normal(size=(20, 8)) + 30\n",
"f, axs = plot.subplots(nrows=3, aspect=1.5, axwidth=3,\n",
" share=0, hratios=(2, 1, 1))\n",
"f, axs = plot.subplots(\n",
" nrows=3, aspect=1.5, axwidth=3,\n",
" share=0, hratios=(2, 1, 1)\n",
")\n",
"axs.format(suptitle='Error bars with various plotting commands')\n",
"axs[1:].format(xlabel='column number', xticks=1, xgrid=False)\n",
"\n",
"# Asking add_errorbars to calculate bars\n",
"ax = axs[0]\n",
"obj = ax.barh(data, color='red orange', means=True)\n",
"ax.format(title='Column statistics')\n",
"ax.format(ylabel='column number', title='Bar plot', ygrid=False)\n",
"\n",
"# Showing a standard deviation range instead of percentile range\n",
"ax = axs[1]\n",
"ax.scatter(data, color='k', marker='x', markersize=50, barcolor='gray5',\n",
" medians=True, barstd=True, barrange=(-1, 1), barzorder=0, boxes=False, capsize=2)\n",
"ax.scatter(\n",
" data, color='k', marker='x', markersize=50, barcolor='gray5',\n",
" medians=True, barstd=True, barrange=(-1, 1), barzorder=0, boxes=False, capsize=2\n",
")\n",
"ax.format(title='Scatter plot')\n",
"\n",
"# Supplying error bar data manually\n",
"ax = axs[2]\n",
"boxdata = np.percentile(data, (25, 75), axis=0)\n",
"bardata = np.percentile(data, (5, 95), axis=0)\n",
"ax.plot(data.mean(axis=0), boxes=False, marker='o', markersize=5,\n",
" edgecolor='k', color='cerulean', boxdata=boxdata, bardata=bardata)\n",
"# Formatting\n",
"axs[0].format(ylabel='column number', title='Bar plot', ygrid=False)\n",
"axs[1].format(title='Scatter plot')\n",
"axs[2].format(title='Line plot')\n",
"axs[1:].format(xlabel='column number', xticks=1, xgrid=False)\n",
"ax.plot(\n",
" data.mean(axis=0), boxes=False, marker='o', markersize=5,\n",
" edgecolor='k', color='cerulean', boxdata=boxdata, bardata=bardata\n",
")\n",
"ax.format(title='Line plot')\n",
"plot.rc.reset()"
]
},
Expand Down Expand Up @@ -177,17 +189,28 @@
"f, axs = plot.subplots(nrows=2, aspect=2, axwidth=3.5, share=0, hratios=(3, 2))\n",
"state = np.random.RandomState(51423)\n",
"data = state.rand(5, 5).cumsum(axis=0).cumsum(axis=1)[:, ::-1]\n",
"data = pd.DataFrame(data,\n",
" columns=pd.Index(np.arange(1, 6), name='column'),\n",
" index=pd.Index(['a', 'b', 'c', 'd', 'e'], name='row idx'))\n",
"data = pd.DataFrame(\n",
" data, columns=pd.Index(np.arange(1, 6), name='column'),\n",
" index=pd.Index(['a', 'b', 'c', 'd', 'e'], name='row idx')\n",
")\n",
"\n",
"# Side-by-side bars\n",
"ax = axs[0]\n",
"obj = ax.bar(data, cycle='Reds', colorbar='ul',\n",
" edgecolor='red9', colorbar_kw={'frameon': False})\n",
"ax.format(xlocator=1, xminorlocator=0.5, ytickminor=False,\n",
" title='Side-by-side', suptitle='Bar plot wrapper demo')\n",
"obj = ax.bar(\n",
" data, cycle='Reds', colorbar='ul',\n",
" edgecolor='red9', colorbar_kw={'frameon': False}\n",
")\n",
"ax.format(\n",
" xlocator=1, xminorlocator=0.5, ytickminor=False,\n",
" title='Side-by-side', suptitle='Bar plot wrapper demo'\n",
")\n",
"\n",
"# Stacked bars\n",
"ax = axs[1]\n",
"obj = ax.barh(data.iloc[::-1, :], cycle='Blues',\n",
" legend='ur', edgecolor='blue9', stacked=True)\n",
"obj = ax.barh(\n",
" data.iloc[::-1, :], cycle='Blues',\n",
" legend='ur', edgecolor='blue9', stacked=True\n",
")\n",
"ax.format(title='Stacked')\n",
"axs.format(grid=False)\n",
"plot.rc.reset()"
Expand Down Expand Up @@ -225,18 +248,22 @@
"state = np.random.RandomState(51423)\n",
"data = state.rand(5, 3).cumsum(axis=0)\n",
"cycle = ('gray3', 'gray5', 'gray7')\n",
"# 2D arrays\n",
"\n",
"# Overlaid and stacked area patches\n",
"ax = axs[0]\n",
"ax.areax(np.arange(5), data, data + state.rand(5)[:, None], cycle=cycle, alpha=0.5,\n",
" legend='uc', legend_kw={'center': True, 'ncols': 2, 'labels': ['z', 'y', 'qqqq']},\n",
" )\n",
"ax.area(\n",
" np.arange(5), data, data + state.rand(5)[:, None], cycle=cycle, alpha=0.5,\n",
" legend='uc', legend_kw={'center': True, 'ncols': 2, 'labels': ['z', 'y', 'qqqq']},\n",
")\n",
"ax.format(title='Fill between columns')\n",
"ax = axs[1]\n",
"ax.area(np.arange(5), data, stacked=True, cycle=cycle, alpha=0.8,\n",
" legend='ul', legend_kw={'center': True, 'ncols': 2, 'labels': ['z', 'y', 'qqqq']},\n",
" )\n",
"ax.area(\n",
" np.arange(5), data, stacked=True, cycle=cycle, alpha=0.8,\n",
" legend='ul', legend_kw={'center': True, 'ncols': 2, 'labels': ['z', 'y', 'qqqq']},\n",
")\n",
"ax.format(title='Stack between columns')\n",
"# Positive and negative colors\n",
"\n",
"# Positive and negative color area patches\n",
"ax = axs[2]\n",
"data = 5*(state.rand(20)-0.5)\n",
"ax.area(data, negpos=True, negcolor='blue7', poscolor='red7')\n",
Expand Down Expand Up @@ -274,19 +301,30 @@
"state = np.random.RandomState(51423)\n",
"f, axs = plot.subplots(ncols=2)\n",
"data = state.normal(size=(N, 5)) + 2*(state.rand(N, 5)-0.5)*np.arange(5)\n",
"data = pd.DataFrame(data, columns=pd.Index(\n",
" ['a', 'b', 'c', 'd', 'e'], name='xlabel'))\n",
"data = pd.DataFrame(\n",
" data,\n",
" columns=pd.Index(['a', 'b', 'c', 'd', 'e'], name='xlabel')\n",
")\n",
"axs.format(\n",
" ymargin=0.1, xmargin=0.1, grid=False,\n",
" suptitle='Boxes and violins demo'\n",
")\n",
"\n",
"# Box plots\n",
"ax = axs[0]\n",
"# , boxprops={'color':'C0'})#, labels=data.columns)\n",
"obj1 = ax.boxplot(data, lw=0.7, marker='x', fillcolor='gray5',\n",
" medianlw=1, mediancolor='k')\n",
"obj1 = ax.boxplot(\n",
" data, lw=0.7, marker='x', fillcolor='gray5',\n",
" medianlw=1, mediancolor='k'\n",
")\n",
"ax.format(title='Box plots', titleloc='uc')\n",
"\n",
"# Violin plots\n",
"ax = axs[1]\n",
"obj2 = ax.violinplot(data, lw=0.7, fillcolor='gray7',\n",
" points=500, bw_method=0.3, means=True)\n",
"ax.format(title='Violin plots', titleloc='uc')\n",
"axs.format(ymargin=0.1, xmargin=0.1, grid=False,\n",
" suptitle='Boxes and violins demo')"
"obj2 = ax.violinplot(\n",
" data, lw=0.7, fillcolor='gray7',\n",
" points=500, bw_method=0.3, means=True\n",
")\n",
"ax.format(title='Violin plots', titleloc='uc')"
]
},
{
Expand Down Expand Up @@ -316,19 +354,25 @@
"N = 50\n",
"cmap = 'IceFire'\n",
"values = np.linspace(-N/2, N/2, N)\n",
"f, axs = plot.subplots(share=0, ncols=2, wratios=(2, 1),\n",
" axwidth='6cm', aspect=(2, 1))\n",
"f, axs = plot.subplots(\n",
" share=0, ncols=2, wratios=(2, 1),\n",
" axwidth='7cm', aspect=(2, 1)\n",
")\n",
"axs.format(suptitle='Parametric plots demo')\n",
"# Smooth gradations\n",
"\n",
"# Parametric line with smooth gradations\n",
"ax = axs[0]\n",
"state = np.random.RandomState(51423)\n",
"m = ax.plot((state.rand(N) - 0.5).cumsum(), state.rand(N),\n",
" cmap=cmap, values=values, lw=7, extend='both')\n",
"ax.format(xlabel='xlabel', ylabel='ylabel',\n",
" title='Line with smooth gradations')\n",
"ax.format(\n",
" xlabel='xlabel', ylabel='ylabel',\n",
" title='Line with smooth gradations'\n",
")\n",
"ax.format(xlim=(-1, 5), ylim=(-0.2, 1.2))\n",
"ax.colorbar(m, loc='b', label='parametric coordinate', locator=5)\n",
"# Step gradations\n",
"\n",
"# Parametric line with stepped gradations\n",
"N = 12\n",
"ax = axs[1]\n",
"values = np.linspace(-N/2, N/2, N + 1)\n",
Expand All @@ -337,8 +381,10 @@
"x = radii*np.cos(1.4*angles)\n",
"y = radii*np.sin(1.4*angles)\n",
"m = ax.plot(x, y, values=values, linewidth=15, interp=False, cmap=cmap)\n",
"ax.format(xlim=(-1, 1), ylim=(-1, 1), title='Step gradations',\n",
" xlabel='cosine angle', ylabel='sine angle')\n",
"ax.format(\n",
" xlim=(-1, 1), ylim=(-1, 1), title='Step gradations',\n",
" xlabel='cosine angle', ylabel='sine angle'\n",
")\n",
"ax.colorbar(m, loc='b', maxn=10, label=f'parametric coordinate')"
]
},
Expand Down Expand Up @@ -374,17 +420,24 @@
"x = (state.rand(20)-0).cumsum()\n",
"data = (state.rand(20, 4)-0.5).cumsum(axis=0)\n",
"data = pd.DataFrame(data, columns=pd.Index(['a', 'b', 'c', 'd'], name='label'))\n",
"# Scatter demo\n",
"\n",
"# Scatter plot with property cycler\n",
"ax = axs[0]\n",
"ax.format(title='Extra prop cycle properties', suptitle='Scatter plot demo')\n",
"obj = ax.scatter(x, data, legend='ul', cycle='warm', legend_kw={'ncols': 2},\n",
" cycle_kw={'marker': ['x', 'o', 'x', 'o'], 'markersize': [5, 10, 20, 30]})\n",
"obj = ax.scatter(\n",
" x, data, legend='ul', cycle='warm', legend_kw={'ncols': 2},\n",
" cycle_kw={'marker': ['x', 'o', 'x', 'o'], 'markersize': [5, 10, 20, 30]}\n",
")\n",
"\n",
"# Scatter plot with colormap\n",
"ax = axs[1]\n",
"ax.format(title='Scatter plot with cmap')\n",
"data = state.rand(2, 100)\n",
"obj = ax.scatter(*data, color=data.sum(axis=0), size=state.rand(100), smin=3, smax=30,\n",
" marker='o', cmap='plum', colorbar='lr', vmin=0, vmax=2,\n",
" colorbar_kw={'label': 'label', 'locator':0.5})\n",
"obj = ax.scatter(\n",
" *data, color=data.sum(axis=0), size=state.rand(100), smin=3, smax=30,\n",
" marker='o', cmap='plum', colorbar='lr', vmin=0, vmax=2,\n",
" colorbar_kw={'label': 'label', 'locator':0.5}\n",
")\n",
"axs.format(xlabel='xlabel', ylabel='ylabel')"
]
}
Expand Down
Loading