0

I have plotted a graph that contains a trig function. Instead of having the x-axis be in radians, I would like it to be in degrees. It's a simple task of multiplying the displayed x-axis values by 180/!pi but I can't figure out how to do it. Let's say I'm trying to graph the cosine function as

q=plot(cos(x))

How can I change the displayed x-axis values to degrees?

FObersteiner
  • 22,500
  • 8
  • 42
  • 72
Bereket
  • 55
  • 8

1 Answers1

2

Just pass the x-values to the plotting routine:

x = findgen(360)
y = cos(x * !dtor)
plot, x, y

Or, if you are using function graphics:

p = plot(x, y)
mgalloy
  • 2,356
  • 1
  • 12
  • 10