add tag
4 years ago JeT

Context

Time series are boring to read without labels…

My question

I’d like to have a systematic approach to comment upon a Time serie, as in this :

ViXEvents.png

  • 1 table to load VIX.dat
  • 1 table with dates of interest I’d like to flag mydates.dat.

M(not so well)WE

Based on this for the metadata in label and this for the vertical line

Top Answer
4 years ago user 3.14159

This answer has two codes:

  1. placing the texts at some absolute y values, and
  2. placing the texts at some fractions of the height of the axis.

It is fairly easy to add the vertical lines around the nodes near coords via append after command. The current output isn’t pretty but in principle this syntax allows you to produce the target plot.

Screen Shot 2021-04-26 at 10.58.26 AM.png

You can also use a scatter plot (recall that nodes near coords is also a scatter plot) to draw the lines and position the nodes at some fraction of the vertical dimension of the plot. (Note that you currently have to set y expr to something reasonable by hand. The styles of the edges and nodes can be controlled via the edges and vnodes keys.)

Screen Shot 2021-04-26 at 1.42.28 PM.png

4 years
JeT replying to user 3.14159 — Tuesday, 27th Apr 2021 16:28

More stable is good, i’ll flag on my (your) code to pay attention there !

user 3.14159 replying to JeT — Tuesday, 27th Apr 2021 16:27

Probably one can make the code more automatic so that it finds the right y expr on its own, but this will result in a longer and possibly less stable code.

JeT replying to user 3.14159 — Tuesday, 27th Apr 2021 16:24

Magic Marmot, thanks !
blob

user 3.14159 replying to JeT — Tuesday, 27th Apr 2021 16:21

As for “If I put an ymin=2000 to have more focuse and less whitespace, I actually lose the labels and lines”, I do not have the code that produces this. However, one reason for the disappearance may be that the y expr is not set appropriately, can you try y expr=3000, say, in this example?

2 hours
JeT — Tuesday, 27th Apr 2021 14:48

Fantastic results… with 1 question.

blob
vs the same news table but applied to another asset
blob
PS : If I put an ymin=2000 to have more focuse and less whitespace, I actually lose the labels and lines

blob

16 hours
JeT replying to user 3.14159 — Monday, 26th Apr 2021 22:32

Great, merci ! I’ll test it and get back to you 😃

an hour
user 3.14159 replying to JeT — Monday, 26th Apr 2021 21:44

I added a prototype version for this as well.

41 minutes
JeT replying to user 3.14159 — Monday, 26th Apr 2021 21:03

Tesing your code on other series like this one.
blob
I realize the position of labels is relative since it’s used in |y.
I actually would prefer them to be fixed on the grid. I presume it must be linked to the axis cs coordinates (?)

an hour
JeT replying to user 3.14159 — Monday, 26th Apr 2021 20:16

Works like a charm ! 1 source of data and so many analysis ahead. Back to work 😃

27 minutes
user 3.14159 replying to JeT — Monday, 26th Apr 2021 19:48

The style of the vertical line can be controlled by adding options to the edges. Try e.g.

Of course this can be made systematic but it is not clear to me how you want to provide the information.

JeT replying to user 3.14159 — Monday, 26th Apr 2021 19:44

@marmot, re: your answer, I would never have found the answer by myself. merci. I’m playing with your code. I can change easily the label color but more tricky to change the vertical line style (dotted, color, etc).
On a practical basis, this feature enables me to use as many mydate.dat as analysis “layers” of my graphs. Multiple lists of financial events to apply to the same intial set of data. No kidding… powerful. Merci Marmot !

39 minutes
JeT replying to user 3.14159 — Monday, 26th Apr 2021 19:05

Merci ! I deleted the useless line in the question.

user 3.14159 replying to samcarter — Monday, 26th Apr 2021 19:03

I agree, I had to make some adjustments to make it compile. I removed the line date VIX in VIX.dat because otherwise I get nonsensical errors, which one may almost call a bug in pgfplots (maybe fixed by now because when I did that I kept \pgfplotsset{compat=1.8}). I also had to repurpose the pos column in the second table.

JeT — Monday, 26th Apr 2021 19:00

I have one error indeed, related to the “\pgfcalendar@datetojulian”, but I get an output. (I am walking on eggs with time series with pgfplots)

31 minutes
samcarter — Monday, 26th Apr 2021 18:29

Is the document actually compiling for you? I do get an error…

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.