# Gadfly - Positioning the legend and entry alignments

**URL:** <https://discourse.julialang.org/t/gadfly-positioning-the-legend-and-entry-alignments/1272>\
**Category:** Visualization\
**Tags:** gadfly\
**Created:** [January 4, 2017, 9:16am UTC](https://discourse.julialang.org/t/gadfly-positioning-the-legend-and-entry-alignments/1272 "2017-01-04T09:16:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![v-i-s-h](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/v-i-s-h/32/46152_2.png) [@v-i-s-h](https://discourse.julialang.org/u/v-i-s-h)\
**Post date:** [January 4, 2017, 9:16am UTC](https://discourse.julialang.org/t/gadfly-positioning-the-legend-and-entry-alignments/1272/1 "2017-01-04T09:16:49Z")

</div>

Hi,

I’m using Gadfly to plot some results. I want to put the legend on top of the figure, but when I use the following code

```julia
results = Dict{String,Array{Float64,1}}()

# Run the experiments and put the observations into 'results' 
# ...
# ...

# Start plotting
penColors = distinguishable_colors( length(testAlgs)+1 )
xPoints = 1:noOfTimeSteps

algStr = [Algorithms.info_str(_alg) for _alg ∈ testAlgs]
fig_reward = Gadfly.plot(
                [ layer( x = xPoints,
                         y = results[algStr[i]],
                         Geom.line,
                         Theme(default_color=penColors[i+1]) ) for i = 1:length(algStr) ]...,
                Guide.xlabel( "Time Step" ),
                Guide.xticks( ticks=collect(0:20:100) ),
                Guide.ylabel( "Average Reward" ),
                Guide.yticks( ticks=collect(0.0:0.1:1.0) ),
                Guide.title( "ϵ-Greedy performance" ),
                Guide.manual_color_key( "", algStr, penColors[2:end] ),
                style(key_position=:top)
            )

```

i get the following figure:

 ![](https://global.discourse-cdn.com/julialang/original/3X/1/7/17ef78524f01cc97578ed223e9ebe1570627f52d.png)

My problem is, here all the entries are crowded towards left.  
**Is there any way to nicely spread them evenly along the horizontal space?**

Thanks,  
vish
