Automate subnet filling

I am writing a python script that (1) will receive a list of y-values ​​for each subtitle to build against a common set of x values, (2) will make each of these subtasks a scatter and put it in the appropriate place in the subtask grid and (3) execute these tasks for different sizes of subgrid meshes. What I mean by the third statement is this: in the test case, I use the results in an array of 64 graphs, 8 rows and 8 columns. I would like the code to be able to process any dimensional array (from about 50 to 80 charts) for various grid sizes without having to return every time I run the code, and say, “Well, here is the number of lines and I need columns.”

I am currently using the exec command to get y values, and this works fine. I can do each of the subheadings and make it fill the grid, but only if I print everything manually (doing the same thing 64 times is just plain stupid, so I know there must be a way to automate this).

Can anyone suggest a way this can be accomplished? I cannot provide data or my code, as this is research material, and I cannot release it. Please excuse me if this question is very simple or something that I should determine from the existing documentation. I am very new to programming and can use a little tutorial!

+4
source share
2

plt.subplots(nrows, ncols), ( numpy) .

:

import matplotlib.pyplot as plt
import numpy as np

fig, axes = plt.subplots(nrows=4, ncols=4, sharex=True, sharey=True)

# "axes" is a 2D array of axes objects.  You can index it as axes[i,j] 
# or iterate over all items with axes.flat

# Plot on all axes
for ax in axes.flat:
    x, y = 10 * np.random.random((2, 20))
    colors = np.random.random((20, 3))
    ax.scatter(x, y, s=80, facecolors=colors, edgecolors='')
    ax.set(xticks=np.linspace(0, 10, 6), yticks=np.linspace(0, 10, 6))

# Operate on just the top row of axes:
for ax, label in zip(axes[0, :], ['A', 'B', 'C', 'D']):
    ax.set_title(label, size=20)

# Operate on just the first column of axes:
for ax, label in zip(axes[:, 0], ['E', 'F', 'G', 'H']):
    ax.set_ylabel(label, size=20)

plt.show()

enter image description here

+4

Python, Python Tutorial, , 101, Python - MIT OCW, edX, ...

, , , :

yvalues = list()
while yvalues_exist:
    yvalues.append(get_yvalue)

#limit plot to eight columns
columns = 8
quotient, remainder = divmod(len(yvalues), columns)
rows = quotient
if remainder:
    rows = rows + 1
for n, yvalue in enumerate(yvalues):
    plt.subplot(rows, columns, n)
    plt.plot(yvalue)

list(), append(), while, divmod(), len(), , for, () - , Python.

0

All Articles