简体   繁体   中英

Multiple Y axes on a single plot Octave

What I am trying to do is create something that looks like this,

阴谋

which I have created by using the Octave pcolor and barh functions using 3 subplots with the subplot x axes scaled to look as if the figure were one plot. However, this approach is unsatisfactory as I cannot zoom or pan across it as I would be able to if it were actually one plot.

How can I plot one background figure using pcolor and then add multiple y axes at different points along the x axis to plot the horizontal histograms using barh?

For some background to this question, I am trying to create what is called a Market Profile chart, ie see example here or here .

I have also cross posted this question on the Octave mailing list here .

I have found a way to do what I want. Instead of using the barh function, one can use the fill function instead.

A minimal, reproducible example given below.

## create y and x axes for chart
y_max = max( high_round ) + max_tick_range * tick_size ;
y_min = min( low_round ) - max_tick_range * tick_size ;
y_ax = ( y_min : tick_size : y_max )' ;
end_x_ax_freespace = 5 ;

x_ax = ( 1 : 1 : numel( open ) + end_x_ax_freespace )' ;
colormap( 'viridis' ) ; pcolor( x_ax , y_ax , vp_z' ) ; shading interp ; axis tight ;

## plot the individual volume profiles
hold on ;
scale_factor = 0.18 ; 
fill( vp( 1 , : ) .* scale_factor , y_ax' , [99;99;99]./255 ) ; 
fill( vp( 2 , : ) .* scale_factor .+ 50 , y_ax' , [99;99;99]./255 ) ;
fill( vp( 3 , : ) .* scale_factor .+ 100 , y_ax' , [99;99;99]./255 ) ;

hold off;

More details on a blog post of mine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM