Plotly subplot produces two graphs with same data, although traces contain different data

时间:2018-08-22 13:48:18

标签: python plotly

When plotting 2 heatmaps, it gives me both heatmaps, each with different settings, but with the data of the first one.

from plotly import tools
import plotly.graph_objs as go
import numpy as np
from plotly.offline import plot

Data:

a = np.array([[1, 2, 3],[1, 2, 3],[1, 2, 3]])
b = np.array([[2, 3, 4],[4, 5, 6],[5, 6, 7]])


fig = tools.make_subplots(rows=1, cols=2)


trace1 = go.Heatmapgl(
        z=a,
        showscale=False,
        colorscale='Viridis',
        name='aa'
     )


trace2 = go.Heatmapgl(
        z=b,
        showscale=False,
        name='bb'
    )


fig.append_trace(trace1, 1, 1)
fig.append_trace(trace2, 1, 2)


plot(fig, filename='simple-subplot')

This gives me 2 heatmaps, but the second one also contains z values of 1, 2 or 3.

Anyone knows what the issue is here?

1 个答案:

答案 0 :(得分:0)

如果您使用较新版本的plotly(我在public class Smartlist { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name = "smartlistId") private Integer smartlistId; @OneToOne( mappedBy = "smartlist", fetch = FetchType.LAZY, cascade = CascadeType.PERSIST, orphanRemoval = true) private AccountEmailing accountEmailing; } @Entity @Table(name = "account_emailing") public class AccountEmailing implements Serializable { @Id @OneToOne @JoinColumn(name = "smartlistId") private Smartlist smartlist; } 上),则可以通过替换原始代码中的几行并应用4.2.0来轻松获得所需的内容。

情节:

enter image description here

代码:

go.Hetmap