Aug-17-2022, 09:55 PM
(Aug-17-2022, 09:06 PM)deanhystad Wrote: Try posting your questions one at a time. I have no idea how to answer everything you've asked so far. I don't really understand what you are asking half the time.
Starting with you last edit. Python thinks ax[index] is indexing a value in a list or array and ax(index) is a function call.
This is where Python sees the error:
And this is what Python thinks the error is:
Error:---> 10 m = p(ax(p), ax(q))
For indexing use [], not ().
Error:TypeError: 'numpy.ndarray' object is not callable
In your first attempt at plotting you got an error because you called the plot function with an invalid argument.
This is where Python sees the error:
And this is what Python thinks the error is:
Error:---> 11 ax[row, col].plot(x, y, color="green", fontsize=18, ha='center')
If you look at the documentation you would see that it does't have a fontsize argument.
Error:AttributeError: 'Line2D' object has no property 'fontsize'
https://matplotlib.org/stable/api/_as_ge....plot.html
if you have additional questions please ask them as new posts to this thread. Do not edit your original post.
Thank you, firstly, I've made the question far more concise. I appreciate your advice on that. Hopefully my questions are clearer now.
Regarding your first point, I've change from () to []:
def plot_global_inf_sub(): n = len(df_transposed.columns) x = years p = 1 i = 0 for c in df_transposed.loc['Aruba':'Zimbabwe']: for p in range(n): for q in range(n): if i <= n: m = p(ax[p], ax[q]) fig, m = plt.subplots(int(n/2), int(n/2)) a = 1 y = df_transposed[c] ax[i,(i-i)].plot(x, y) ax[i, a(i=+1)].plot(x, y) plt.show() plot_global_inf_sub()And now get the following error:
Error:---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/var/folders/7n/v1x237vx47z_7y3g2_63b64h0000gs/T/ipykernel_6003/19824294.py in <module>
16 plt.show()
17
---> 18 plot_global_inf_sub()
/var/folders/7n/v1x237vx47z_7y3g2_63b64h0000gs/T/ipykernel_6003/19824294.py in plot_global_inf_sub()
8 for q in range(n):
9 if i <= n:
---> 10 m = p(ax[p], ax[q])
11 fig, m = plt.subplots(int(n/2), int(n/2))
12 a = 1
TypeError: 'int' object is not callable
It's good for me to read and understand your error/explanation reply, thank you.