# "plot of array with wrong number of components (!= 2 or 3) "

**URL:** <https://community.freefem.org/t/plot-of-array-with-wrong-number-of-components-2-or-3/2245>\
**Category:** General Discussion\
**Created:** [January 25, 2023, 11:45am UTC](https://community.freefem.org/t/plot-of-array-with-wrong-number-of-components-2-or-3/2245 "2023-01-25T11:45:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)\
**Post date:** [January 25, 2023, 11:45am UTC](https://community.freefem.org/t/plot-of-array-with-wrong-number-of-components-2-or-3/2245/1 "2023-01-25T11:45:40Z")

</div>

I keep trying to copy these examples with plot and except for very simple  
things they end up making errors. I can’t see the difference betwneen  
my code and the file I copied it from.  
The excerpt below is from the example Stokes-v3-matrix-mumps.edp  
with a plot line taken from one of the other examples with variables  
changed . I’ve seen this error before but no idea what is wrong.

Also, I noted that when viewing a plot at the end after solution all the other  
cores were maxxed out still- gdb showed at least one was in a spin wait loop  
or similar. You can waste the cores if that is all the thing is doing but in this  
case I can give up some speed so my browser can run lol. I think this is why  
I have a bad attitude towards MPI- stepping on each other for memory  
etc makes a mess very easily. Is there some way to get the other mpiranks  
to exit while rank zero is showing the plots? Thanks.

````auto
//if(mpirank==0) medit("UV2 PV2",Th,[u1,u2,u3],p);
if(mpirank==0) plot([u1,u2],p,value=true,coef=.2,wait=1,cmm="[u1,u2] - p ");
//plot([Ux, Uy], p, value=true, coef=0.2, cmm="[Ux, Uy] - p");

```123 : 
  124 : //if(mpirank==0) medit("UV2 PV2",Th,[u1,u2,u3],p);
  125 : if(mpirank==0) plot([u1,u2],p,value=true,coef=.2,wait=1,cmm="[u1,u2] - p ")
 Error line number 125, in file Stokes-v3-matrix-mumps.edp, before token )
plot of array with wrong number of components (!= 2 or 3) 
  current line = 125 mpirank 0 / 8
Compile error : plot of array with wrong number of components (!= 2 or 3) 
	line number :125, )
error Compile error : plot of array with wrong number of components (!= 2 or 3) 
	line number :125, )
````

---

<div class="post-metadata">

**Author:** ![julienG](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/julieng/32/222_2.png) [@julienG](https://community.freefem.org/u/julienG)\
**Post date:** [January 25, 2023, 4:54pm UTC](https://community.freefem.org/t/plot-of-array-with-wrong-number-of-components-2-or-3/2245/2 "2023-01-25T16:54:38Z")

</div>

I think that as it says

> [@marchywka](#):
>
> ` plot([u1,u2],p,...`

has wrong dimension. In 2d, `plot([u1,u2],p,...` is correct, but in 3d I think it expects a 3-component array: `plot([u1,u2,u3],p,...`

---

<div class="post-metadata">

**Author:** ![marchywka](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@marchywka](https://community.freefem.org/u/marchywka)\
**Post date:** [January 25, 2023, 5:35pm UTC](https://community.freefem.org/t/plot-of-array-with-wrong-number-of-components-2-or-3/2245/3 "2023-01-25T17:35:35Z")

</div>

Thanks that seems to work and I never would have guessed that.
