Gnopol changes axes

I would like to reproduce this plot using gnuplot:

enter image description here

My data has the following format:


Data 1: Time
2: Price
3: Volume

I tried this:

plot file using 1:2 with lines, '' using 1:3 axes x1y2 with impulses

This gives a normal time series chart with y1both price and y2volume.
Then I tried:

plot file using 2:1 with lines, '' using 2:3 axes x1y2 with impulses 

What gives a series of prices with y1both time and y2volume. However, I need to keep the price at the level y1and the volume at the level x2.

Maybe something like:

plot file using 1:2 with lines,' ' using 2:3 axes y1x2 with impulses

However, this does not give what I want.

0
source share
1 answer

Gnuplot . boxxyerrorbars ( boxxy).

, . python script:

from numpy import zeros, savetxt, random

N = 500
g = zeros(N)
for i in range(1, N):
    g[i] = g[i-1] + random.normal()

savetxt('randomwalk.dat', g, delimiter='\t', fmt='%.3f')

, " " ( ). smooth frequency. y x -. binning, (x + - binwidth/2). , x y :

binwidth = 2
hist(x) = floor(x+0.5)/binwidth

set output "| head -n -2 > randomwalk.hist"
set table
plot 'randomwalk.dat' using (hist($1)):(1) smooth frequency
unset table
unset output

set table "randomwalk.hist", - , , . "set table" Gnuplot ?.

:

unset key
set x2tics
set xtics nomirror

set xlabel 'time step'
set ylabel 'position value'
set x2label 'frequency'

set style fill solid 1.0 border lt -1

set terminal pngcairo
set output 'randwomwalk.png'

plot 'randomwalk.hist' using ($2/2.0):($1*binwidth):($2/2.0):(binwidth/2.0) with boxxy lc rgb '#00cc00' axes x2y1,\
     'randomwalk.dat' with lines lc rgb 'black'

( 4.6.3, , , ):

enter image description here

, script:

reset
binwidth = 2
hist(x) = floor(x+0.5)/binwidth
file = 'data.txt'
histfile = 'pricevolume.hist'

set table histfile
plot file using (hist($2)):($3) smooth unique
unset table

# get the number of records to skip the last one
stats histfile using 1 nooutput

unset key
set x2tics
set xtics nomirror

set xlabel 'time'
set ylabel 'price'
set x2label 'volume'

set style fill solid 1.0 border lt -1

plot histfile using ($2/2.0):($1*binwidth):($2/2.0):(binwidth/2.0) every ::::(STATS_records-2) with boxxy lc rgb '#00cc00' axes x2y1,\
     file with lines using 1:2 lc rgb 'black'

, table stats every (, STATS_records-2), 0). .

smooth unique, , ( smooth frequency).

+2

All Articles