No problem. :)




On Tue, May 20, 2014, at 08:55 PM, Dan B wrote:

Thanks Daniel!  Works perfectly!  Very much appreciated :)

On Tuesday, May 20, 2014 8:43:55 PM UTC-7, Daniel Jones wrote:

I agree, that should work. I'll try to fix it when I have a chance.

In the mean time, a work around would be to use
levels=collect(xs) where xs is your vector of names. That will
effectively convert the PooledDataArray to a regular Array, so should
work.


On Tue, May 20, 2014, at 08:25 PM, Dan B wrote:

>From one Daniel to the next - thanks! :)  This looks like exactly what
I need.  If I try manually constructing a vector with the names like
you did, then it does order the bars.  However, if I try to pass in an
array, I get the following.  Please note - Im new to Julia so I may
have some misunderstanding about how array substitution works, or have
made a newbie syntax error.  Based on your example though this seemed a
logical substitution.

Thanks!



usingGadfly;

set_default_plot_size(30cm, 18cm)

plot(results,y="count",x="name",

Scale.x_discrete(levels=results["name"]),

Scale.y_continuous(format=:plain),

Scale.discrete_color_manual("#6084b4","#69b461","#8d72b4","#60a6b4","#b460b4","#
eea34b","#cc5266","#cb96d6","#75c7eb","#a1d6bb"),

color="name",

Geom.bar,

Guide.xlabel("Name"), Guide.ylabel("Tests"), Guide.title("Title"),

Theme(panel_fill=color("#ffffff"), panel_stroke=color("#ffffff"), grid_color=col
or("#e1e3e5"),

minor_label_color=color("#4e5c67"), bar_spacing=2mm))




no method PooledDataArray{T,R<:Integer,N}(DataArray{UTF8String,1}, DataArray{UTF
8String,1})
 in discretize at /home/ubuntu/.julia/v0.3/Gadfly/src/scale.jl:280
 in apply_scale at /home/ubuntu/.julia/v0.3/Gadfly/src/scale.jl:367
 in apply_scales at /home/ubuntu/.julia/v0.3/Gadfly/src/scale.jl:28
 in apply_scales at /home/ubuntu/.julia/v0.3/Gadfly/src/scale.jl:48
 in render at /home/ubuntu/.julia/v0.3/Gadfly/src/Gadfly.jl:624
 in draw at /home/ubuntu/.julia/v0.3/Gadfly/src/Gadfly.jl:730
 in writemime at /home/ubuntu/.julia/v0.3/Gadfly/src/Gadfly.jl:755
 in sprint at io.jl:460
 in display_dict at /home/ubuntu/.julia/v0.3/IJulia/src/execute_request.jl:27





results["name"]



Out[40]:
10-element DataArray{UTF8String,1}:
 "Name 1"
 "Name 2"


"Name 3"

"Name 4"

"Name 5"

"Name 6"

"Name 7"

"Name 8"

"Name 9"

"Name 10"


On Tuesday, May 20, 2014 7:23:26 PM UTC-7, Daniel Jones wrote:


It should work if you add:

Scale.x_discrete(levels=["a", "b", "c"])

where ["a", "b", "c"] is a vector of the values in the order you'd like
them to appear.



On Tue, May 20, 2014, at 05:32 PM, Dan B wrote:

Friends,

I have a simple array that has counts (sorted descending) and names
associated with each count (please see screenshot).  When I plot a bar
chart with name on the X axis, and count on the Y axis, the bars get
automatically sorted alphabetically by the names on the Y axis.  I
would like to have the bars sorted ascending or descending by the Y
axis (the count), essentially to match the order that I have in the
array.  Am I missing something simple?

Thanks in advance!

- - Dan

  Email had 1 attachment:
  * BarChartOrderingIssue.png
  *   76k (image/png)

Reply via email to