Hi Chris,
I was busy this week, hence couldn’t try your suggestion out earlier. However, I have tried it out now, and yet I face the same issue.
Here I am posting the same code in its entireity.
#my code
import plotly.plotly as py
import plotly.graph_objs as go
import numpy as np
import pandas as pd
import dash_core_components as dcc
import dash_html_components as dh
from dash.dependencies import Input, Output
from app import app
ctr0 = ctr1 = ctr2 = ctr3 = 0
b = pd.read_excel(‘H:\PLA data\sort PLA.xlsx’,sheetname = ‘Input new data’)
book = b.sort_values([‘Solution description’],ascending=True)
L = len(book.index)
PLA = np.zeros(L)
DMSO = np.zeros(L)
EtOH = np.zeros(L)
Color = np.zeros(L)
for i in xrange(L):
PLA[i]=book.loc[i,‘PLA, g’]
DMSO[i]=book.loc[i,‘DMSO, g’]
EtOH[i]=book.loc[i,‘Ethanol, g’]
Color[i]=book.loc[i,‘Solution description’]
for j in range(len(PLA)):
if Color[j]==0:
ctr0+=1
if Color[j]==1:
ctr1+=1
if Color[j]==2:
ctr2+=1
if Color[j]==3:
ctr3+=1
c1=ctr0+ctr1
c2=ctr1+ctr2+ctr0
c3=ctr2+ctr3+ctr1+ctr0
ctr0=ctr0
def getPLA(ctr,ct,c):
k=0
store = np.zeros©
while (k<c):
store[k] = PLA[k+ctr]
format(store[k],’.2f’)
k+=1
return store.tolist()
def getEtOH(ctr,ct,c):
k=0
store = np.zeros©
while (k<c):
store[k] = EtOH[k+ctr]
format(store[k],’.2f’)
k+=1
return store.tolist()
def getDMSO(ctr,ct,c):
k=0
store = np.zeros©
while (k<c):
store[k] = DMSO[k+ctr]
format(store[k],’.2f’)
k+=1
return store.tolist()
def getText(a,rho,size): #(color,pore density, pore size)
text = []
if (a==0):
text = 'Liquid Solution’
if (a==1):
text = 'Two - Liquid Solution’
if (a==2):
text = 'Solid - Liquid Solution’
if (a==3):
text = ‘Gel’
Liquid_Solution = {
“a”: [i for i in getPLA(0,ctr0,ctr0)],
“asrc”: “deeptanshu:19:5206a2”,
“b”: [i for i in getDMSO(0,ctr0,ctr0)],
“bsrc”: “deeptanshu:19:71c2df”,
“c”: [i for i in getEtOH(0,ctr0,ctr0)],
“csrc”: “deeptanshu:19:9e2788”,
“marker”: {
“color”: “#1F77B4”,
“line”: {“width”: 2},
“size”: 14,
“symbol”: 200
},
“mode”: “markers”,
“name” : ‘Liquid Solution’,
“opacity” : 0.7,
“text”: [‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,‘liquid solution’,],
“textsrc”: “deeptanshu:19:b28dd3”,
“type”: “scatterternary”
}
Two_Liquid_Solution = {
“a”: [i for i in getPLA(ctr0,c1,ctr1)],
“asrc”: “deeptanshu:19:5206a2”,
“b”: [i for i in getDMSO(ctr0,c1,ctr1)],
“bsrc”: “deeptanshu:19:71c2df”,
“c”: [i for i in getEtOH(ctr0,c1,ctr1)],
“csrc”: “deeptanshu:19:9e2788”,
“marker”: {
“color”: “#D62728”,
“line”: {“width”: 2},
“size”: 14,
“symbol”: 200
},
“mode”: “markers”,
“name” : ‘Two Liquid Solution’,
“opacity” : 0.7,
“text”: [‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’,‘2 Liqiuid solution’],
“textsrc”: “deeptanshu:19:b28dd3”,
“type”: “scatterternary”
}
Solid_Liquid_Solution = {
“a”: [i for i in getPLA(c1,c2,ctr2)],
“asrc”: “deeptanshu:19:5206a2”,
“b”: [i for i in getDMSO(c1,c2,ctr2)],
“bsrc”: “deeptanshu:19:71c2df”,
“c”: [i for i in getEtOH(c1,c2,ctr2)],
“csrc”: “deeptanshu:19:9e2788”,
“marker”: {
“color”: “#2CA02C”,
“line”: {“width”: 2},
“size”: 14,
“symbol”: 200
},
“mode”: “markers”,
“name” : ‘Solid-Liquid Solution’,
“hoveron” : “points+fills”,
“opacity” : 0.8,
“text”: [‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’,‘Solid-Liquid Solution’],
“textsrc”: “deeptanshu:19:b28dd3”,
“type”: “scatterternary”
}
Gel = {
“a”: [i for i in getPLA(c2,c3,ctr3)],
“asrc”: “deeptanshu:19:5206a2”,
“b”: [i for i in getDMSO(c2,c3,ctr3)],
“bsrc”: “deeptanshu:19:71c2df”,
“c”: [i for i in getEtOH(c2,c3,ctr3)],
“csrc”: “deeptanshu:19:9e2788”,
“marker”: {
“color”: “#444444”,
“line”: {“width”: 2},
“size”: 14,
“symbol”: 200
},
“mode”: “markers”,
“name” : ‘Gel’,
“opacity” : 0.96,
“hoveron” : “points+fills”,
“text”: [‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’,‘Gel’],
“textsrc”: “deeptanshu:19:b28dd3”,
“type”: “scatterternary”
}
data = [Liquid_Solution,Two_Liquid_Solution,Solid_Liquid_Solution,Gel]
lay = {
“height” : 900,
“autosize” : True,
“showlegend”: True,
“annotations”: [
{
“x”: 0.5,
“y”: 1.05,
“font”: {“size”: 25},
“showarrow”: True,
“text”: “Ternary PLA/DMSO/EtOH plot\n at 65°C”
}
],
“ternary”: {
“aaxis”: {
“showgrid”: True,
“color” : “#0f0”,
“showline”: True,
“tickangle”: 0,
“tickcolor”: “#0f0”,
“ticksuffix”: “%”,
“tickfont”: {“size”: 15},
“ticklen”: 10,
“min” : 0.2,
“title”: “PLA”,
“titlefont”: {“size”: 20},
},
“baxis”: {
“showgrid”: True,
“color” : “#000”,
“showline”: True,
“tickangle”: 60,
“tickcolor”: “#000”,
“ticksuffix”: “%”,
“tickfont”: {“size”: 15},
“ticklen”: 10,
“min” : 0.2,
“title”: “
DMSO”,
“titlefont”: {“size”: 20}
},
“caxis”: {
“showgrid”: True,
“color” : “00a”,
“showline”: True,
“tickangle”: -60,
“tickcolor”: “#00a”,
“ticksuffix”: “%”,
“tickfont”: {“size”: 15},
“ticklen”: 10,
“min” : 0.2,
“title”: “
EtOH”,
“titlefont”: {“size”: 20}
},
“sum”: 100
},
“width” : 900
}
app.layout = dh.Div([
dh.Div(id=‘app-1-display-value’),
dcc.Graph(
id=‘plot’,
figure={
‘data’: data,
‘layout’: lay
}
),
#dcc.Location(id=‘url’,refresh=False),
dh.Br(),
dcc.Link(‘Go to 80°C’,href=’/dash80.py’),
dh.Label(‘Enter the data to be added\n’),
dh.Label(‘PLA concentration\n’),
dcc.Input(
placeholder=’\n\n\n’,
type=‘number’,
value=10,
id=‘PLA’
),
dh.Label(‘DMSO concentration\n’),
dcc.Input(
placeholder=’\n\n\n’,
type=‘number’,
value=k,
id=‘DMSO’
),
dh.Label(‘EtOH concentration\n’),
dcc.Input(
placeholder=’\n\n\n’,
type=‘number’,
value=’’,
id=‘EtOH’
),
dh.Button(‘Click Me’, id=‘my-button’),
])
@app.callback(
Output(‘app-1-display-value’, ‘children’),
[Input(‘PLA’, ‘value’)])
def display_value(value):
return ‘You have selected “{}”’.format(value)
if name == ‘main’:
app.run_server(debug=True)
The other file dash80.py is pretty similar to this only that it takes records for its plotting from a different page on the excel workbook. Am I making a categorical mistake somewhere or is there something missing in the code.