# Getting different markers shapes

**URL:** <https://community.plotly.com/t/getting-different-markers-shapes/9944>\
**Category:** 📊 Plotly Python\
**Created:** [April 26, 2018, 8:38pm UTC](https://community.plotly.com/t/getting-different-markers-shapes/9944 "2018-04-26T20:38:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![t3c](https://avatars.discourse-cdn.com/v4/letter/t/3ec8ea/32.png) [@t3c](https://community.plotly.com/u/t3c)\
**Post date:** [April 26, 2018, 8:38pm UTC](https://community.plotly.com/t/getting-different-markers-shapes/9944/1 "2018-04-26T20:38:01Z")

</div>

This is my first post and is similar to this one ([Different marker shapes in 3d scatter plot](https://community.plotly.com/t/different-marker-shapes-in-3d-scatter-plot/4530)), but I can’t seem to get anything to work in python. First off, I am trying to make a multi-line graph (which I have done in both plt and plotly…code below), but being colorblind (which I am) I can’t often tell what I am looking in plotly because the markers are always a circle (even though the label is included, it sometimes gets cut off and I can’t figure out what I’m looking at).

I am using Jupyter Notebook ##(version: 5.4.0)  
Python ##(version 3.6.4)

# Screenshot of the dummy\_data file.

 ![dummy_data_screenshot](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/8/82ece84b8d13838e3d8cb55011995afdcc66feb7.JPG)

In matplotlib, I did the following to get the output attached (note the different shape markers):

```auto
import matplotlib as mpl ##(version: 2.1.2)
import pandas as pd ##(version: 0.22.0)
import numpy as np ##(version: 1.14.0)

import plotly.graph_objs as go
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
import cufflinks as cf ##(version: 0.12.1)

init_notebook_mode(connected=True)
cf.go_offline()

%matplotlib notebook

fx = df.groupby(['studyarm', 'visit'])['totdiffic_chg'].mean().unstack('studyarm').drop(['02_UNSCH','ZEOS'])

valid_markers = ([item[0] for item in mpl.markers.MarkerStyle.markers.items() if 
item[1] is not 'nothing' and not item[1].startswith('tick') 
and not item[1].startswith('caret')])

markers = np.random.choice(valid_markers, df.shape[1], replace=False)
ax = fx.plot(kind = 'line', linestyle='-')
for i, line in enumerate(ax.get_lines()):
    line.set_marker(markers[i])
ax.legend(loc='best')
ax.set_xticklabels(df.index, rotation=45)
plt.title('Some Made Up Data')
plt.ylabel('Score', fontsize=14)
plt.autoscale(enable=True, axis='x', tight=True)
plt.tight_layout()

```

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/e/e1eabeec358d68ca99d08327578c4ce4136879ba.png)

I used the code below and it created the graph via plotly/cufflinks:

```auto
fx.iplot(kind='line', yTitle='Score', title='Some Made Up Data', mode=markers,\
           filename='cufflinks/simple-line')
```

 ![newplot](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/c/c501752f1661c59dfb8ddfae204c245caa9e2908.png)

I have searched the web for the last few days and I can see many options to change the color, opacity, etc., etc., but I can’t seem to figure out a way to automatically and randomly change the shape of the markers OR to manually change each individual line to a separate marker shape.

I am sure this is a simple fix, but I can’t figure it out. Any help (or nudge in the right direction) would be very much appreciated.!

---

<div class="post-metadata">

**Author:** ![jack](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jack/32/11_2.png) [@jack](https://community.plotly.com/u/jack)\
**Post date:** [April 27, 2018, 4:03am UTC](https://community.plotly.com/t/getting-different-markers-shapes/9944/2 "2018-04-27T04:03:36Z")

</div>

First, you need to have cufflinks return the plot as a plotly figure:

```auto
fig = fx.iplot(kind='line', yTitle='Score', title='Some Made Up Data', mode=markers, asFigure=True)

```

Then, you need to set the marker symbol for each trace. Available marker symbols are listed here (all of the ones in your matplotlib example are available): [https://plot.ly/python/reference/#scatter-marker-symbol](https://plot.ly/python/reference/#scatter-marker-symbol)

To set the symbol of the first trace, for example:

```auto
fig['data'][0]['marker']['symbol'] = 'triangle-left'

```

---

<div class="post-metadata">

**Author:** ![t3c](https://avatars.discourse-cdn.com/v4/letter/t/3ec8ea/32.png) [@t3c](https://community.plotly.com/u/t3c)\
**Post date:** [April 30, 2018, 6:02pm UTC](https://community.plotly.com/t/getting-different-markers-shapes/9944/3 "2018-04-30T18:02:03Z")

</div>

Hi Jack,

Thank You for your response. It works! Now I will start to mess with the code to autogenerate these.
