2

I'm trying to determine if it's possible to display the underlying data points on a Gadfly chart. I know that I can display the labels associated with a particular point, but how can I show the actual values on the chart, itself?

For example, from the Gadfly documentation, let's say I have this chart:

plot(x=rand(10), y=rand(10))

How can I display the resulting values in the x and y vectors on the chart itself?

Jeremy McNees
  • 787
  • 4
  • 16

2 Answers2

4

Actually, it's easy to get a string representation, e.g. string(3).

How about the following:

using Gadfly

N = 10
xx = rand(1:10, N)  # N random integers between 1 and 10
yy = rand(1:10, N)

labels = map(string, zip(x,y))

plot(x=xx, y=yy, label=labels, Geom.label, Geom.point)

This gives something like the following:

points labelled by coordinates

David P. Sanders
  • 5,210
  • 1
  • 23
  • 23
1

One way to do this is to feed the values into Gadfly via a labels string vector:

label_vec = ["4", "4", "7", "7", "9", "1", "8", "10", "11", "2"]

plot(x=rand(10), y=rand(10), Labels = label_vec, Geom.label)

It's a pain to parse ints/floats into strings though, it would be nice if you could feed them directly into Gadfly as ints/floats.

Does anyone have a better way?

Jeremy McNees
  • 787
  • 4
  • 16