Python Forum
Nested for loops - help with iterating a variable outside of the main loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Nested for loops - help with iterating a variable outside of the main loop
#2
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:
Error:
---> 10 m = p(ax(p), ax(q))
And this is what Python thinks the error is:
Error:
TypeError: 'numpy.ndarray' object is not callable
For indexing use [], not ().


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:
Error:
---> 11 ax[row, col].plot(x, y, color="green", fontsize=18, ha='center')
And this is what Python thinks the error is:
Error:
AttributeError: 'Line2D' object has no property 'fontsize'
If you look at the documentation you would see that it does't have a fontsize argument.

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.
Reply


Messages In This Thread
RE: Nested for loops - by deanhystad - Aug-17-2022, 09:06 PM
RE: Nested for loops - by dm222 - Aug-17-2022, 09:55 PM
RE: Nested for loops - by dm222 - Aug-17-2022, 10:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Variable definitions inside loop / could be better? gugarciap 2 505 Jan-09-2024, 11:11 PM
Last Post: deanhystad
  How to create a variable only for use inside the scope of a while loop? Radical 10 1,960 Nov-07-2023, 09:49 AM
Last Post: buran
  reduce nested for-loops Phaze90 11 2,015 Mar-16-2023, 06:28 PM
Last Post: ndc85430
  Big O runtime nested for loop and append yarinsh 4 1,445 Dec-31-2022, 11:50 PM
Last Post: stevendaprano
  Nested for loops: Iterating over columns of a DataFrame to plot on subplots dm222 0 1,762 Aug-19-2022, 11:07 AM
Last Post: dm222
  loop (create variable where name is dependent on another variable) brianhclo 1 1,183 Aug-05-2022, 07:46 AM
Last Post: bowlofred
  breaking out of nested loops Skaperen 3 1,285 Jul-18-2022, 12:59 AM
Last Post: Skaperen
  Multiple Loop Statements in a Variable Dexty 1 1,242 May-23-2022, 08:53 AM
Last Post: bowlofred
Big Grin Variable flag vs code outside of for loop?(Disregard) cubangt 2 1,218 Mar-16-2022, 08:54 PM
Last Post: cubangt
  How to save specific variable in for loop in to the database? ilknurg 1 1,190 Mar-09-2022, 10:32 PM
Last Post: cubangt

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020