https://linen.dev logo
Title
t

tan tan

05/25/2023, 9:46 PM
hi, how I can customize the order of grouped bar chart label, https://observablehq.com/@observablehq/plot-grouped-bar-chart?intent=fork, the sort function is always based on the value, is it possible to pass an custom order list directly, for example :
order = ["FL","BY","CA","TX","IL","PA"]
, so it's neither alphabet order nor x,y value based. For no grouped bar chart, I can do it via
x: { domain: order }
, but for grouped bar chart, that one was used inside for each group.
m

Michael Cooper

05/25/2023, 9:48 PM
The axis you want to sort isn't
x
, but
fx
. Try
fx: { domain: order }
. That's "facet x"
I'm not 100% if that will work quite right. If it doesn't can you share the notebook you're working in?
t

tan tan

05/25/2023, 9:50 PM
the link is in my description
m

Michael Cooper

05/25/2023, 9:51 PM
oh, apologies
t

tan tan

05/25/2023, 9:51 PM
it's fine, always appreciate anyone's response
m

Michael Cooper

05/25/2023, 9:52 PM
ok, yes. setting the domain of
fx
works for me: https://observablehq.com/d/dd878dcd8ebbc322
t

tan tan

05/25/2023, 9:53 PM
do you know when I should use
fx
, I think the variable name confuses me
I felt like I always have to ask someone for help and feel a little bit guilty on that, it was way too frequent
m

Michael Cooper

05/25/2023, 9:54 PM
fx
is the channel name for the horizontal facet direction. You'd use that if you want to affect the facets of the chart, and you'd use
x
when you want to affect the horizontal channel within one chart
in that chart the
x
channel is the age groups, and it is repeated several times, once for each facet. The
fx
channel is the State abbreviation (TX, CA, etc), and it only happens once
does that help?
t

tan tan

05/25/2023, 9:58 PM
@Michael Cooper so for a single (not grouped) regular bar chart, there is only one facet?
m

Michael Cooper

05/25/2023, 9:59 PM
I'd think about it as not being faceted, but I think only having one facet is correct too
t

tan tan

05/25/2023, 10:02 PM
and channel in this case is a list of items that was used for each facet. I was trying to understand the relationship in and out I guess
cuz inside each facet is a full graph technically
m

Michael Cooper

05/25/2023, 10:03 PM
a channel is the way that Plot talks about how you can visually encode data https://observablehq.com/plot/features/marks#marks-have-channels
m

Mihael Ankerst

05/25/2023, 10:03 PM
Maybe here the terminology is a bit confusing: In general faceting means adding one or more dimensions based on which you "replicate" your main Plot for each category. This notebook is called Grouped bar chart, in Plot you generally use group, like Plot.group(..) for aggregating data based on a categorical attribute
m

Michael Cooper

05/25/2023, 10:04 PM
You're right, that notebook has nothing to do
Plot.group
, which is a bit confusing
t

tan tan

05/25/2023, 10:05 PM
the
Plot.group
is used for grouping the rawdata before they are used for rendering right?
not the group we are talking about here
m

Michael Cooper

05/25/2023, 10:06 PM
yeah. it would be more correct to say that the notebook is demonstrating a faceted bar chart, not a grouped one
t

tan tan

05/25/2023, 10:06 PM
this is actually one of the official example
grouped is pretty common term used for this kind of illustration in terms of user facing, but I'm not sure about the correct mathematical term though
m

Michael Cooper

05/25/2023, 10:07 PM
I'm one of the official employees 😉. I can pass this along to our docs team
👀 1
😂 1
f

Fabian Iwand

05/25/2023, 10:08 PM
I also suspect that grouped was chosen for familiarity, as mentioned by @tan tan. The best docs aren't worth much if you can't find them 😁
m

Michael Cooper

05/25/2023, 10:11 PM
I would recommend reading the new Plot docs. We launched them a few weeks ago, and in my opinion they are an excellent way to learn the library: https://observablehq.com/plot/
1
including lots of examples
t

tan tan

05/25/2023, 10:14 PM
It really depends on the reader's background,
group
can be confusing for developer like me cuz there are some common terms used inside the code (mathematically) and outside of the code (daily life) that hold completely different meanings. But maybe it makes sense for general data science people. 😂 idk, just a user feedback I guess
not just group, I think I will also encounter other terms here and there