Skip to content

Commit

Permalink
fix the xlim, ylim zooms in the widget notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
lheagy committed Aug 13, 2020
1 parent f6912ce commit 8d14f1b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions 1-widgets-an-example.ipynb
Expand Up @@ -184,7 +184,7 @@
" if ax is None:\n",
" fig, ax = plt.subplots(1, 1, figsize=(8, 5))\n",
" \n",
" y = slope * (dates - dates.min()) + intercept\n",
" y = slope * (dates - np.min(dates)) + intercept\n",
" ax.plot(dates, y, label=label)"
]
},
Expand Down Expand Up @@ -381,6 +381,9 @@
" year_predict - 1, predicted_co2_recent, \n",
" f\"{predicted_co2_recent:1.2f} ppm\", ha=\"right\", va=\"center\"\n",
" )\n",
" \n",
" ax.set_xlim(xlim)\n",
" ax.set_ylim(ylim)\n",
"plot_predictions()"
]
},
Expand Down Expand Up @@ -409,12 +412,12 @@
"widgets.interactive(\n",
" plot_predictions, \n",
" xlim=widgets.IntRangeSlider(\n",
" min=co2_data[\"date\"].min(), max=year_predict+1, \n",
" value=[int(co2_data[\"date\"].min()), year_predict+1], \n",
" min=co2_data[\"date\"].min()-1, max=year_predict+1, \n",
" value=[int(co2_data[\"date\"].min())-1, year_predict+1], \n",
" continuous_update=False\n",
" ),\n",
" ylim=widgets.IntRangeSlider(\n",
" min=300, max=420, value=[300, 420], continuous_update=False\n",
" min=250, max=500, value=[250, 475], continuous_update=False\n",
" ),\n",
" \n",
")"
Expand Down

0 comments on commit 8d14f1b

Please sign in to comment.