Title: Plot embedded meshes with python
Tags: python;matplotlib
Question: I have data, where each point is an element of a 4 dimensional array. More precisely, it is a coarse mesh in each element of which I have a smaller mesh. Say the coarse mash is 2x2 and in each of the mesh elements I have another smaller mesh which is 3x3. The question is how to plot that with python. What I do is to find the global position of each of the fine mesh elements and plot it with scatter plot. This works, but I was thinking whether it could be done more efficiently, without the necessity to compute the global indexes.

To illustrate my point consider the following minimal example

```import matplotlib.pyplot as plt
import numpy as np

def from4to2d(i1,j1,i2,j2,nx,ny):
   return (i1*nx + i2, j1*ny + j2)



nx=ny=3 # 3x3 fine mesh

x=[]
y=[]
z=[]

for i1 in range(0,2):
  for j1 in range(0,2):
    for i2 in range(0,3):
      for j2 in range(0,3):
    a,b = from4to2d(i1,j1,i2,j2,nx,ny)
    x+=[a]
    y+=[b]
    z+=[a*b]


plt.scatter(x, y, c=z ,s=200, marker='s',cmap=mpl.cm.spectral,linewidths=0)
plt.savefig('fig.png',dpi=200,bbox_inches='tight')
```

The question is, if I could do the same without having to find the global positions via ```from4to2d(i1,j1,i2,j2,nx,ny)```.

Comment: you'll need to add a self-contained example that demonstrates how you're generating this data structure and what you've already tried in terms of visualizing it.

Comment: so what exactly do you want? A plot with dots? polygons? help us out here and include some more details and examples of what you're trying to do?

Comment: @PaulH I included a minimal example.



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 3, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2016:00:03/11/16', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<python><matplotlib>', 'Title': 'Plot embedded meshes with python', 'ViewCount': 135, 'id': 35950455, 'user_AboutMe': None, 'user_AccountId': 2230482.0, 'user_DisplayName': 'Alexander Cska', 'user_Reputation': 729.0, 'user_Views': 222.0, 'user_id': 1968203.0}}