![]() It is a GUI, and we need to inform it immediately that we are intending to make this plot 3D. What doe this mean, you ask? Well, Matplotlib just literally displays a window in a typical frame. So, the first new thing you see is we've defined our figure, which is pretty normal, but after plt.figure() we have. threedee = plt.figure().gca(projection='3d') ![]() ![]() Now, let's get to the good stuff! Let's say we are curious to compare price and H-L together, to see if there's any sort of correlation with H-L and price visually. df = pd.read_csv('sp500_ohlc.csv', parse_dates=True)ĭf = pd.rolling_mean(df, 100)Ībove, we have typical code that you've already seen in this series, no need to expound on it. Let's get to the code: import pandas as pdĪbove, everything looks pretty typical, besides the fourth import, which is where we import the ability to show a 3D axis. That is alright though, because we can still pass through the Pandas objects and plot using our knowledge of Matplotlib for the rest. We can do wire frames, bars, and more as well! If there's a way to plot with Pandas directly, like we've done before with df.plot(), I do not know it. There are many other things we can compare, and 3D Matplotlib is not limited to scatter plots. In this tutorial, we show that not only can we plot 2-dimensional graphs with Matplotlib and Pandas, but we can also plot three dimensional graphs with Matplot3d! Here, we show a few examples, like Price, to date, to H-L, for example.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |