Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
guilhermesilva
Regular Visitor

Power BI shows plotly graph in the browser instead of Power BI framework with python

Hi There!

Right now I can use plotly with Power BI via Python. 

However, it shows the graph in another window:

guilhermesilva_0-1642538579974.png

Inside of Power BI I get this:

guilhermesilva_1-1642538611375.png

It says: It is not possible to show this visual. No Image was created. Check whether your Python script results in a standard device graph of Python.

 

Here is my code:

 

# dataset = pandas.DataFrame(Predito_Acumulado, Predito_Acumulado_l, Predito_Acumulado_u, DT_CONTATO)
# dataset = dataset.drop_duplicates()
# Cole ou digite aqui seu código de script:
baux = dataset
import plotly.graph_objs as go

fig = go.Figure([
    
    go.Scatter(
        name='Máximo',
        x=baux['DT_CONTATO'],
        y=baux['Predito_Acumulado'],
        mode='lines',
        line=dict(color='rgb(31, 119, 180)'),
    ),
    go.Scatter(
        name='Predição',
        x=baux['DT_CONTATO'],
        y=baux['Predito_Acumulado_u'],
        mode='lines',
        marker=dict(color="#444"),
        line=dict(width=0),
        showlegend=False
    ),
    go.Scatter(
        name='Mínimo',
        x=baux['DT_CONTATO'],
        y=baux['Predito_Acumulado_l'],
        marker=dict(color="#444"),
        line=dict(width=0),
        mode='lines',
        fillcolor='rgba(68, 68, 68, 0.3)',
        fill='tonexty',
        showlegend=False
    )
])
fig.update_layout(
    yaxis_title='Número de Matrículas',
    hovermode="x"
)
fig.show()

 

Thanks!!

1 ACCEPTED SOLUTION
v-janeyg-msft
Community Support
Community Support

Hi, @guilhermesilva 

 

Check this in the doc:

  • Only plots that are plotted to the Python default display device are displayed correctly on the canvas. Avoid explicitly using a different Python display device.

vjaneygmsft_0-1642746011485.png

I'm not good at Python, I suggest you test whether a simple graph can be displayed normally, if not, you can rule out the code problem.

Make sure you have properly configured the python script:

Use an external Python IDE with Power BI - Power BI | Microsoft Docs

 

Did I answer your question? Please mark my reply as solution. Thank you very much.
If not, please feel free to ask me.

Best Regards,
Community Support Team _ Janey

View solution in original post

1 REPLY 1
v-janeyg-msft
Community Support
Community Support

Hi, @guilhermesilva 

 

Check this in the doc:

  • Only plots that are plotted to the Python default display device are displayed correctly on the canvas. Avoid explicitly using a different Python display device.

vjaneygmsft_0-1642746011485.png

I'm not good at Python, I suggest you test whether a simple graph can be displayed normally, if not, you can rule out the code problem.

Make sure you have properly configured the python script:

Use an external Python IDE with Power BI - Power BI | Microsoft Docs

 

Did I answer your question? Please mark my reply as solution. Thank you very much.
If not, please feel free to ask me.

Best Regards,
Community Support Team _ Janey

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.