Plotly repeating graphs everytime I ask for a plot even when I change the data


I have been struggling with a problem for several hours and cant find anything that helps me.

I am trying to get data from some db files and make a 3D histogram with it. It works fine, but when I try to run the graph line multiple times, it plots the same graph every time even when I am changing the data to plot.

This is the code (I simplified it so that I dont have to post 500 lines, but the error is the same and this is the piece that makes the error, I believe the other part is not causing any trouble).

The thing is, I dont know how to link the databases so you can reproduce the program. Any hint would be so much appreciated.

If, anyways, you could know what is causing this with the code, that would be great!

import sqlite3
import pandas as pd
import plotly.offline as py

class MultiFT:
    name1 --> First nominal variable
    name2 --> Second nominal variable
    var1 --> First continuous variable
    var2 --> Second continuous variable
    All of them being strings
def __init__(self, name1, name2, var1, var2): = None
    self.name1 = name1
    self.name2 = name2
    self.var1 = var1
    self.var2 = var2

    # Get close and variation for each company

 conn1 = sqlite3.Connection('stock_prices_yahoo_test/' + self.name1 + '.db')
    conn2 = sqlite3.Connection('stock_prices_yahoo_test/' + self.name2 + '.db')
    self.com1 = pd.read_sql("SELECT " + self.var1 + ", " + self.var2 + " FROM " + self.name1, con = conn1)
    self.com2 = pd.read_sql("SELECT " + self.var1 + ", " + self.var2 + " FROM " + self.name2, con = conn2)

def threeD_hist(self, frame, y = None):
    traces = []
    x = frame.iloc[:, 0]
    x = x.values
    # There might be a bug or something but I had to hardcode the y axis
    y = ['[0.0, 0.67)', '[0.67, 1.33)', '[1.33, 2.0)', '[2.0, 2.66)', '[2.66, 3.33)',
            '[3.33, 3.99)', '[3.99, 4.66)', '[4.66, 5.32)', '[5.32, 5.99]']
    z = frame.iloc[1:, 1:]
    z = z.values

            z = z,
            x = x,
            y = y,
            type = 'surface'

    fig = { 'data':traces, 'layout':{'title': 'Histograma 3D de la FT `de Apple'}}`
    py.plot(fig, filename = '_3D_hist.html')

def get_data_from_db(self, db, table):
    conn = sqlite3.Connection('stock_prices_yahoo_test/' + db + '.db')
    dat = pd.read_sql("SELECT * FROM " + table, con = conn)
    return dat

k = MultiFT('AAPL', 'BTC_EUR', 'Close', 'PerVar')

frame1 = k.get_data_from_db('_multiFT', 'multiFT_AAPL')

# This is where things get dirty
frame2 = k.get_data_from_db('_multiFT', 'multiFT_AAPL_ranged')

And this is the error I get, although it is like nothing I had seen before and can not find anything related in the internet to fix it.

/usr/bin/xdg-open: line 881: x-www-browser: command not found
/usr/bin/xdg-open: line 881: x-www-browser: command not 
foun[verdi07@localhost practica2]$ Created new window in e[verdi07@localhost practica2]$ [Parent 18369, Gecko_IOThread] 
WARNING: pipe error (107): Connection reset by peer: file 
64.0/ipc/chromium/src/chrome/common/, line 363
[Parent 18369, Gecko_IOThread] WARNING: pipe error (73): Connection 
reset by peer: file /builddir/build/BUILD/firefox- 
64.0/ipc/chromium/src/chrome/common/, line 363

Your attention is very much appreciated :slight_smile:


Hi @verdi07,

Nothing stands out to me after reading through your code. If you print the traces object inside threeD_hist (Using print(traces)) do you see different data between the two calls? Also, try changing the filename argument between calls in case something is going wrong when overwriting the previous file.

To share the database, could you upload the sqlite database file to something like google drive or dropbox and the post a public link?




It seems using the same filaname caused the error, thanks!