Export plot to pdf and have it appear as in python

How do I export this plot to pdf and have it appear as it does in python?
I specified:
width=1400,
height=400,
and used
fig.write_image(‘path/plot.pdf’, engine=“kaleido”)

This is the intended plot as it appears in python:

This is the plot when exported to pdf.

Hey @Donnsi welcome to the forums.

Could you please provide a reproducible example? What OS are you using?

Hey @AIMPED, here’s a reproducible example. I’m using Windows OS.

import numpy as np
import plotly.graph_objects as go
import plotly.io as pio

date_range = pd.date_range(start='2014-01-01', end='2014-01-07', freq='h')

np.random.seed(42)
internal_air_temp = 20 + 2 * np.sin(np.linspace(0, 3 * np.pi, len(date_range)))
ambient_temp = 10 + 3 * np.cos(np.linspace(0, 3 * np.pi, len(date_range)))
battery_temp = 25 + np.random.normal(0, 0.5, len(date_range))
hvac_power = np.abs(np.random.normal(2, 0.5, len(date_range)))  # in kW
battery_losses = np.abs(np.random.normal(0.5, 0.1, len(date_range)))  # in kW

fig = go.Figure()

fig.add_trace(go.Scatter(
    x=date_range,
    y=internal_air_temp,
    name='Internal Air Temp (°C)',
    line=dict(color='maroon'),
    yaxis='y1'
))

fig.add_trace(go.Scatter(
    x=date_range,
    y=ambient_temp,
    name='Ambient Temp (°C)',
    line=dict(color='green'),
    yaxis='y1'
))

fig.add_trace(go.Scatter(
    x=date_range,
    y=battery_temp,
    name='Battery Temp (°C)',
    line=dict(color='black'),
    yaxis='y1'
))

fig.add_trace(go.Scatter(
    x=date_range,
    y=hvac_power,
    name='HVAC Thermal Power (kW)',
    line=dict(color='lightblue'),
    yaxis='y2'
))

fig.add_trace(go.Scatter(
    x=date_range,
    y=battery_losses,
    name='Battery Losses (kW)',
    line=dict(color='orange'),
    yaxis='y2'
))

fig.update_layout(
    title=dict(text='Temperatures, Battery Losses and HVAC Operation - Example', font=dict(size=22)),
    font=dict(size=18),
    width=1400,
    height=400,
    xaxis=dict(
        title=dict(text='Time', font=dict(size=18)),
        tickfont=dict(size=18),
        showline=True,
        linecolor='black',
        linewidth=2
    ),
    yaxis=dict(
        title=dict(text='Temperature (°C)', font=dict(size=18)),
        tickfont=dict(size=18),
        side='left',
        showline=True,
        linecolor='black',
        linewidth=2,
        showgrid=False
    ),
    yaxis2=dict(
        title=dict(text='Power (kW)', font=dict(size=18)),
        tickfont=dict(size=18),
        overlaying='y',
        side='right',
        showline=True,
        linecolor='black',
        linewidth=2,
        showgrid=False
    ),
    legend=dict(
        font=dict(size=18),
        orientation='h',
        yanchor='bottom',
        y=1.02,
        xanchor='left',
        x=0
    ),
    plot_bgcolor='white',
    paper_bgcolor='white'
)

fig.show()
fig.write_image('plot.pdf', engine="kaleido")

Thank you @Donnsi !

I can’t reproduce this on Ubuntu22.04:

plotly: v6.0.0
kaleido: v0.2.1