I am trying to build a lot of data using subtitles and I have no problem, but I am wondering if there is a convenience method for this.
Below is a sample code.
import numpy as np
import math
import matplotlib.pyplot as plt
quantities=["sam_mvir","mvir","rvir","rs","vrms","vmax"
,"jx","jy","jz","spin","m200b","m200c","m500c","m2500c"
,"xoff","voff","btoc","ctoa","ax","ay","az"]
ncol = 5
nrow = math.ceil(21 / ncol)
fig, axes = plt.subplots(nrows = nrow, ncols=ncol, figsize=(8,6))
for i in range(nrow):
for j in range(((21-i*5)>5)*5 + ((21-i*5)<5)*(21%5)):
axes[i, j].plot(tree[quantities[i*ncol + j]])
axes[i, j].set_title(quantities[i*ncol + j])
This code moves through a two-dimensional array of subheadings and stops on the 21st chart, leaving 4 panels empty. My question is, is there a built-in method to accomplish this task? For example, make an array of two-dimensional submarines and βsmoothβ the array into 1D, then collapse the array through 1D through 0 ... 20.
The expression in the second range () is very ugly. I donβt think I will use this code. I think the trivial way is to count the number of graphs and break if count> 21. But I just wonder if there is a better (or fancy) way.