# Square Contour Plots

**URL:** <https://community.plotly.com/t/square-contour-plots/6921>\
**Category:** 📊 Plotly Python\
**Created:** [November 21, 2017, 11:16am UTC](https://community.plotly.com/t/square-contour-plots/6921 "2017-11-21T11:16:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luka.j.v](https://avatars.discourse-cdn.com/v4/letter/l/ecd19e/32.png) [@luka.j.v](https://community.plotly.com/u/luka.j.v)\
**Post date:** [November 21, 2017, 11:16am UTC](https://community.plotly.com/t/square-contour-plots/6921/1 "2017-11-21T11:16:37Z")

</div>

I am quite new to Plotly so bear with me if these are simple questions, the first is that I cannot seem to get square contour plots. My code is the following;

```
fig = go.Figure(data=data, layout=layout)
py.iplot(fig, filename='Reflection')

data = [
    go.Contour(
        z=A,
    x=n,
    y=k,
    colorscale='plasma',
    scaleratio = 0,
    ),
]
py.iplot(data, filename='Absorption Contour')

```

But the graph I get looks like this;

[https://plot.ly/~luka.j.v/18.embed](https://plot.ly/~luka.j.v/18.embed)

FYI n and k and both ndarrays with dimensions 31 and A is a ndarray with dimensions (31x31)

Also I can’t seem to change the colours of the plot, as you can see I have tried to use colourscale=‘plasma’ but I am getting the same as the default.

---

<div class="post-metadata">

**Author:** ![empet](https://avatars.discourse-cdn.com/v4/letter/e/977dab/32.png) [@empet](https://community.plotly.com/u/empet)\
**Post date:** [November 21, 2017, 3:53pm UTC](https://community.plotly.com/t/square-contour-plots/6921/2 "2017-11-21T15:53:54Z")

</div>

@luka.j.v

1. The Plotly `contour` trace has no attribute `scaleratio`. Choosing an adequate layout width and height you can adjust the size of plot as you want. When you experiment a new trace just check [https://plot.ly/python/reference](https://plot.ly/python/reference)  
and choose from the left menu the corresponding trace to see its attributes.

2. Plotly has no ‘plasma’ colorscale. Here [https://github.com/plotly/plotly.py/blob/f52c5dbaa8c0084f2ada5e444aecbcd321db30db/plotly/colors.py](https://github.com/plotly/plotly.py/blob/f52c5dbaa8c0084f2ada5e444aecbcd321db30db/plotly/colors.py) you can find the Plotly colors and colorscales.

To convert a matplotlib (like `plasma`) or cmocean colormap to a Plotly colorscale

use this function:

```
import cmocean
import numpy as np
import matplotlib.cm as cm

def mpl_to_plotly(cmap, pl_entries):
    h=1.0/(pl_entries-1)
    pl_colorscale=[]
    for k in range(pl_entries):
        C=map(np.uint8, np.array(cmap(k*h)[:3])*255)
        pl_colorscale.append([round(k*h,2), 'rgb'+str((C[0], C[1], C[2]))])
return pl_colorscale

plotly_plasma=mpl_to_plotly(cm.plasma, 11)
```
