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
#4
(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:
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.

Sorry I've done exactly what you've said not to do, ask new questions and edited the original post. If you can, can you briefly explain why so I can post better in the future. I don't want a bad reputation and annoy responders.
Thanks.
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 514 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 2,016 Nov-07-2023, 09:49 AM
Last Post: buran
  reduce nested for-loops Phaze90 11 2,031 Mar-16-2023, 06:28 PM
Last Post: ndc85430
  Big O runtime nested for loop and append yarinsh 4 1,450 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,774 Aug-19-2022, 11:07 AM
Last Post: dm222
  loop (create variable where name is dependent on another variable) brianhclo 1 1,188 Aug-05-2022, 07:46 AM
Last Post: bowlofred
  breaking out of nested loops Skaperen 3 1,300 Jul-18-2022, 12:59 AM
Last Post: Skaperen
  Multiple Loop Statements in a Variable Dexty 1 1,248 May-23-2022, 08:53 AM
Last Post: bowlofred
Big Grin Variable flag vs code outside of for loop?(Disregard) cubangt 2 1,228 Mar-16-2022, 08:54 PM
Last Post: cubangt
  How to save specific variable in for loop in to the database? ilknurg 1 1,195 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