|
42 | 42 | # level for all circles to deal with overplotting.
|
43 | 43 | fig.plot(x=x, y=y, style="c0.15c", fill=fill, transparency=50)
|
44 | 44 |
|
45 |
| -# Shift the plot origin and add top margin histogram. |
46 |
| -fig.shift_origin(yshift=height + 0.25) |
| 45 | +# Shift the plot origin in y direction temporarily and add top margin histogram. |
| 46 | +with fig.shift_origin(yshift=height + 0.25): |
| 47 | + fig.histogram( |
| 48 | + projection=f"X{width}/3", |
| 49 | + frame=["Wsrt", "xf", "yaf+lCounts"], |
| 50 | + # Give the same value for ymin and ymax to have them calculated automatically. |
| 51 | + region=[xmin, xmax, 0, 0], |
| 52 | + data=x, |
| 53 | + fill=fill, |
| 54 | + pen="0.1p,white", |
| 55 | + histtype=0, |
| 56 | + series=0.2, |
| 57 | + ) |
47 | 58 |
|
48 |
| -fig.histogram( |
49 |
| - projection=f"X{width}/3", |
50 |
| - frame=["Wsrt", "xf", "yaf+lCounts"], |
51 |
| - # Give the same value for ymin and ymax to have them calculated automatically. |
52 |
| - region=[xmin, xmax, 0, 0], |
53 |
| - data=x, |
54 |
| - fill=fill, |
55 |
| - pen="0.1p,white", |
56 |
| - histtype=0, |
57 |
| - series=0.2, |
58 |
| -) |
59 |
| - |
60 |
| -# Shift the plot origin and add right margin histogram. |
61 |
| -fig.shift_origin(yshift=-height - 0.25, xshift=width + 0.25) |
62 |
| - |
63 |
| -# Plot the horizontal histogram. |
64 |
| -fig.histogram( |
65 |
| - horizontal=True, |
66 |
| - projection=f"X3/{height}", |
67 |
| - # Note that the x- and y-axis are flipped, with the y-axis plotted horizontally. |
68 |
| - frame=["wSrt", "xf", "yaf+lCounts"], |
69 |
| - region=[ymin, ymax, 0, 0], |
70 |
| - data=y, |
71 |
| - fill=fill, |
72 |
| - pen="0.1p,white", |
73 |
| - histtype=0, |
74 |
| - series=0.2, |
75 |
| -) |
| 59 | +# Shift the plot origin in x direction temporarily and add right margin histogram. |
| 60 | +with fig.shift_origin(xshift=width + 0.25): |
| 61 | + # Plot the horizontal histogram. |
| 62 | + fig.histogram( |
| 63 | + horizontal=True, |
| 64 | + projection=f"X3/{height}", |
| 65 | + # Note that the x- and y-axes are flipped, with the y-axis plotted horizontally. |
| 66 | + frame=["wSrt", "xf", "yaf+lCounts"], |
| 67 | + region=[ymin, ymax, 0, 0], |
| 68 | + data=y, |
| 69 | + fill=fill, |
| 70 | + pen="0.1p,white", |
| 71 | + histtype=0, |
| 72 | + series=0.2, |
| 73 | + ) |
76 | 74 | fig.show()
|
0 commit comments