Hi,
I am trying to use 2 xaxis (same yaxis) on a plot. Basically, I want to have different labels on the top X-axis and the bottom X-axis, and I thought it would be possible by creating 2 traces, with one of them being empty but using its xaxis. Basically, I would like to have the following plot, but with different labels in the top x-axis:
It is not working. This is the code:
import plotly
import numpy as np
outputFile = "out.html"
cols=10
rows=100
dataD = np.random.rand(10,100)
names = ["name1", "name2","name3","name4","name5",\
"name6", "name7","name8","name9","name10"]
nums = ["2", "3","1","2","12","3", "2","28","1","40"]
final_data1=[]
final_data2=[]
for i in range(dataD.shape[0]):
conf = {
"type": "violin",
"x0": names[i],
"y": dataD[i,:],
"name": names[i],
"xaxis": "x1",
"yaxis": "y"
}
final_data1.append(conf)
topNum= {
"type": "violin",
"x0": nums[i],
"y": [],
"showlegend": False,
"xaxis": "x2",
"yaxis": "y"
}
final_data2.append(topNum)
fig = {
"data": [final_data1,final_data2],
"layout" : {
"title": "Random title",
"xaxis": {
"showgrid":True,
"showline":True,
"tickangle": 270,
"side":"bottom",
"anchor": "y"
},
"xaxis2":{
"overlaying":"x1",
"side":"top",
"anchor": "y"
},
"yaxis": {
"zeroline": False,
},
"hovermode": "closest"
}
}
plotly.offline.plot(fig, filename=outputFile, validate = False)
This is the output:
I do not even understand why the labels go from -1 to 6.
Cheers