bdeonovic
bdeonovic

Reputation: 4220

julia: Change printed function output

In julia when a function is called it automatically prints the output to the console i.e.

julia> [1:10]+5
10-element Array{Int64,1}:
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15

I'm using Gadfly's plotting functions, which creates a plot. The output looks atrocious though. I don't want to completely suppress the output though (I think that can be done using the ;). I want to retain the summary portion (in the above example 10-element Array{Int64,1})

How can I do that?

Upvotes: 1

Views: 244

Answers (1)

mbauman
mbauman

Reputation: 31362

If I'm understanding you correctly, the simple solution is to define a show method for Gadfly's plots:

Base.show(io::IO,p::Gadfly.Plot) = print(io, summary(p))

You can make it more complicated to show more information about p if you wish. In most cases, though, I think Gadfly should actually generate an image of the plot and show it to you (through the richer display mechanism).

Upvotes: 2

Related Questions