简体   繁体   中英

Loop plotly orca

I'm new on python then sorry for my question. I'm just trying to learnt it. I googled it but I dind't see any good answer for my question so I'm here:)

I'm doing a loop to graph some columns on my dataset with python and plotly.

import plotly.figure_factory as ff

for columns in data.columns[1:-1]:
    x1 = data.loc[df.TARGET==0, columns]
    x2 = data.loc[df.TARGET==1, columns]
    fig = ff.create_distplot([x1,x2], group_labels,  show_rug=False)
    fig.update(layout_title_text=columns)
    fig.show()

Its only print one graph and after I'm getting this error:

ValueError: 
For some reason plotly.py was unable to communicate with the
local orca server process, even though the server process seems to be running.

Please review the process and connection information below:

orca status
-----------
    state: running
    executable: C:\ProgramData\Anaconda3\orca.CMD
    version: 1.3.1
    port: 55590
    pid: 7804
    command: ['C:\\ProgramData\\Anaconda3\\orca.CMD', 'serve', '-p', '55590', '--plotly', 'C:\\ProgramData\\Anaconda3\\lib\\site-packages\\plotly\\package_data\\plotly.min.js', '--graph-only', '--mathjax', 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js']

Anyone could help?

Thanks in advance!

There are three things missing from your question to make it reproducible

  1. data
  2. df
  3. group_labels

I've defined these by inducing content from your code. This runs without any issue in my JupyterLab env, producing 4 graphs

import pandas as pd
import numpy as np
import plotly.figure_factory as ff

data = pd.DataFrame({**{"TARGET":np.random.randint(0,2,500)},**{f"c{n}":np.random.randn(500)*1.5**n for n in range(5)}})
df = data
group_labels = ["A","B"]

for columns in data.columns[1:-1]:
    x1 = data.loc[df.TARGET==0, columns]
    x2 = data.loc[df.TARGET==1, columns]
    fig = ff.create_distplot([x1,x2], group_labels,  show_rug=False)
    fig.update(layout_title_text=columns)
    fig.show()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM