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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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