These are chat archives for sandialabs/toyplot

7th
Apr 2017
Deren Eaton
@dereneaton
Apr 07 2017 17:34
@tshead this might be a simple question, but I'm having trouble figuring out how to change the placement of a barplot on a cartesian grid beyond using the baseline='stacked' option. Or, more specifically, how to make a barplot start above the 0-axis and still be able to set a stroke element on the bars without it also showing up in the 'hidden' stacked portion of the bars. Example below:
## make one set of axes
canvas = toyplot.Canvas(width=250, height=350)
axes = canvas.cartesian()

## generate data
colors = toyplot.color.Palette()
a = np.random.random(20)
b = 1-a

## 'stacked' at +1 x
heights = np.column_stack(([1 for i in range(a.shape[0])], zip(a,b)))
axes.bars(heights, 
          baseline="stacked",
          along='y', 
          color=['transparent', colors[0], colors[1]],
          )

## 'stacked' at +3 x
heights = np.column_stack(([3 for i in range(a.shape[0])], zip(a,b)))
axes.bars(heights, 
          baseline="stacked",
          along='y', 
          color=['transparent', colors[0], colors[1]],
         )
blob
So, that works just fine without a stroke, but:
## 'stacked' at +1 x
heights = np.column_stack(([1 for i in range(a.shape[0])], zip(a,b)))
axes.bars(heights, 
          baseline="stacked",
          along='y', 
          color=['transparent', colors[0], colors[1]],
          style={"stroke": "black", "stroke-width": 1}, 
          )

## 'stacked' at +3 x
heights = np.column_stack(([3 for i in range(a.shape[0])], zip(a,b)))
axes.bars(heights, 
          baseline="stacked",
          along='y', 
          color=['transparent', colors[0], colors[1]],
         );
blob
When a stroke is added the transparent area becomes outlined as well. I'd like to be able to place a barplot to start at a certain baseline position but not actually plot the bars below that position. Maybe there could be an option for simplly entering baseline={int} for something like this.
Deren Eaton
@dereneaton
Apr 07 2017 17:40
Oh, wait, it looks like you can already do that. Lol, my bad. Thanks!