#!/usr/bin/gnuplot
# gnuplot 4.2
# gnuplot script for plotting eurofxref-hist.csv as obtained from
# http://www.federalreserve.gov/datadownload/Choose.aspx?rel=H10
# Code modified from: https://commons.wikimedia.org/wiki/File:USD_rate_to_CNY.svg
# Gorgo < https://commons.wikimedia.org/wiki/User:Gorgo >, CC BY-SA 3.0
# download and unzip data if not available
! [ -f FRB_H10.csv ] || wget -O FRB_H10.csv "http://www.federalreserve.gov/datadownload/Output.aspx?rel=H10&series=c5d6e0edf324b2fb28d73bcacafaaa02&lastObs=&from=01/01/1971&to=05/01/2019&filetype=csv&label=include&layout=seriescolumn"
#input
set timefmt "%Y-%m"
set datafile missing 'ND'
set datafile separator ','
#output
set key top left
set style data lines
set grid
set xdata time
set format x '%Y'
set xtics 157680000
set xrange ['1980-01':'2019-05']
#set mxtics 4
set ylabel 'CNY'
set format y '%.2f'
set term svg size 800,400 font "Arial,10"
set outp 'USD rate to CNY from 1980 to 2019.svg'
set style line 1 lt rgb 'blue' lw 1.5
#available currencies:
#first one is $2, second $3 and so on
#Currency:USD,USD,USD,USD,BRL,CAD,CNY,DKK,HKD,INR,JPY,MYR,MXN,NOK,ZAR,SGD,KRW,LKR,SEK,CHF,TWD,THB,VEB
plot 'FRB_H10.csv' every ::6 usi 1:($8) title '1 USD in CNY' ls 1