Equivalent of d3's "step-after" interpolation?

I’ve been doing some work with d3 recently. It’s certainly been an education… Out of the box, it supports several different types of interpolation between two points, which I’ve found quite useful. It allows me to focus on assembling my data, and not worry about transforming it to achieve the desired visual effect. For example, in trading markets, once a trade is seen at a certain price, X, it’s useful to think of that price holding until the next trade price seen at Y. With d3’s “step-after” interpolation, given two points, (t0, X) and (t1, Y), instead of drawing a single line between the two points, it draws a horizontal line between (t0, X) and (t1, X), then a vertical line between (t1, X) and (t1, Y).

I’ve don’t a bit of searching, but didn’t find anything obviously like this in matplotlib. Does it support such a feature?

Thx,

Skip

Kinda sounds a bit like a barchart with the ‘step’ option, I think?

···

On Thu, Oct 30, 2014 at 12:16 PM, Skip Montanaro <skip@…789…> wrote:

I’ve been doing some work with d3 recently. It’s certainly been an education… Out of the box, it supports several different types of interpolation between two points, which I’ve found quite useful. It allows me to focus on assembling my data, and not worry about transforming it to achieve the desired visual effect. For example, in trading markets, once a trade is seen at a certain price, X, it’s useful to think of that price holding until the next trade price seen at Y. With d3’s “step-after” interpolation, given two points, (t0, X) and (t1, Y), instead of drawing a single line between the two points, it draws a horizontal line between (t0, X) and (t1, X), then a vertical line between (t1, X) and (t1, Y).

I’ve don’t a bit of searching, but didn’t find anything obviously like this in matplotlib. Does it support such a feature?

Thx,

Skip



Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

···

On Oct 30, 2014, at 11:29AM, Benjamin Root wrote:

Kinda sounds a bit like a barchart with the 'step' option, I think?

On Thu, Oct 30, 2014 at 12:16 PM, Skip Montanaro <skip@...789...> wrote:
I've been doing some work with d3 recently. It's certainly been an education... Out of the box, it supports several different types of interpolation between two points, which I've found quite useful. It allows me to focus on assembling my data, and not worry about transforming it to achieve the desired visual effect. For example, in trading markets, once a trade is seen at a certain price, X, it's useful to think of that price holding until the next trade price seen at Y. With d3's "step-after" interpolation, given two points, (t0, X) and (t1, Y), instead of drawing a single line between the two points, it draws a horizontal line between (t0, X) and (t1, X), then a vertical line between (t1, X) and (t1, Y).

I've don't a bit of searching, but didn't find anything obviously like this in matplotlib. Does it support such a feature?

Thx,

Skip

------------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Kinda sounds a bit like a barchart with the 'step' option, I think?

Almost, but not quite. I think of barcharts as displaying truly
discrete data, often with the dependent variable being a count of some
sort and the independent variable being a bucket. In my example, while
prices X and Y are constrained to be discrete by the nature of the
market (US stocks trade in one cent increments, for example), they are
connected in time, and there is no fixed "bucket" size (time
increment).

python - How do I plot a step function? - Stack Overflow

Thanks, that's exactly what I needed. I wasn't using the correct terms
when searching Google. I was thinking "interpolation," not "step
function."

Skip

You might also be interested in http://stackoverflow.com/questions/15188005/linestyle-in-matplotlib-step-function
which details the `drawstyle` parameters. It can be set to 'steps-post' for example.

The only case I was not able to cover with this parameter are the fill_between plots, because they do not use Line objects...

···

--
Pierre

is a much better example of how to control the step function.

···

On Thu, Oct 30, 2014 at 1:01 PM, Pierre Haessig <pierre.haessig@...1709...> wrote:

You might also be interested in
python - Linestyle in matplotlib step function - Stack Overflow
which details the `drawstyle` parameters. It can be set to 'steps-post'
for example.

The only case I was not able to cover with this parameter are the
fill_between plots, because they do not use Line objects...

--
Pierre

------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
Thomas Caswell
tcaswell@...287...