Hi.
I've been trying to create subplots with MatPlotLib, FinPlot, Ta-Lib, and Seaborn. Constant errors. I've tried Python V 3.9.x and 3.10.x using both PyCharm and Visual Studio Code using my own code and multiple samples of code copied from the internet. Here is one sample:
In another test function that I created using a datafreme loaded with a custom CSV file, this code:
Thanks for any advice,
Dan.
p.s. Platform Specs:
I've been trying to create subplots with MatPlotLib, FinPlot, Ta-Lib, and Seaborn. Constant errors. I've tried Python V 3.9.x and 3.10.x using both PyCharm and Visual Studio Code using my own code and multiple samples of code copied from the internet. Here is one sample:
# ----------- Test ------------ plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig, (ax1, ax2) = plt.subplots(2) df = pd.DataFrame(dict(name=["Joe", "James", "Jack"], age=[23, 34, 26])) df.set_index("name").plot(ax=ax1) df.set_index("name").plot(ax=ax2) plt.show() # ----------- End Test ------------Note that Matplotlib and pandas are declared at the top of the script:
import matplotlib.pyplot as plt import pandas as pdWhen executed, it throws this error on the "df = pd.DataFrame(..." command:
Error:local variable 'pd' referenced before assignment
The code comes from: Tutorials Point - Article "Stuffing a Pandas DataFrame.plot into a Matplotlib subplot". This seems like a reputable site and presumably, the code should work.In another test function that I created using a datafreme loaded with a custom CSV file, this code:
# ... fig, (ax1, ax2) = plt.subplots(2) df_cur_daily("Close").plot(ax=ax1) df_cur_daily("High").plot(ax=ax2) plt.show()Throws this error when it hits
df_cur_daily("Close").plot(ax=ax1)
Error:'DataFrame' object is not callable
I've been banging my head on this for hours on many tests like this. I'd appreciate any help. Is there any reason this python code will not work correctly in VS Code? Another approach to plotting a chart? Another library?Thanks for any advice,
Dan.
p.s. Platform Specs:
- Apple Macbook Pro M1 Max (latest)
- 32 GB
- Python 3.9.10
- MacOS Monterey V12.3
- Visual Studio Code V1.65.2 (Universal)