Closed ManavalanG closed 2 years ago
Thanks for the question! I assume you mean fixing the min/max of the y-axis so that it is not locally determined from the data. This can be accomplished using the domain
property on the y
encoding.
import gosling as gos
data = gos.multivec(
url="https://resgen.io/api/v1/tileset_info/?d=UvVPeLHuRDiYA3qwFlm7xQ",
row="sample",
column="position",
value="peak",
categories=["sample 1"],
binSize=5,
)
track = gos.Track(data).mark_bar().encode(
x="start:G",
xe="end:G",
-- y="peak:Q",
++ y=gos.Y("peak:Q", domain=[0, 0.0005]),
stroke=gos.value("white"),
strokeWidth=gos.value(0.5),
).properties(layout="linear", width=725, height=180)
track.view(title="Basic Marks: Bar", subtitle="Tutorial Examples")
Thanks for the quick response. Sorry my question wasn't clear.
Using the input bed file (an example below), I would like to draw a bar chart and the bars should have a constant y value of 5 where ymin=0 and ymax=20, for example,.
#chrom start end size_mb
chr2 188576793 189661479 1.08
chr6 34145900 35787881 1.64
chr6 111096151 112132983 1.04
I can't use pandas because of HPC limitations to manipulate this data to add another column and then supply it to gosling. Also, due to system limitations, I would not be able to add a column to this file, save it to disk and then load it to gosling. So I wonder if I can directly supply this constant value to gosling for Y.
I also looked into data transform but didn't find a solution.
Hi @ManavalanG, you could set the top and bottom positions of bars with constant px values using y
and ye
(link to the JS online editor-(G'y4(GCpeakKWOK'axisNrightK'domain4%5B0J20%5DG)G)G%5Djsize4(I5)6)6%5D%0A)%20%20-%2CG4!%206%0A9'JWC'fieldNG6*I'value4J%2C%20K'-N4'OquantitativeW'typeNX'tracks4%5BZamplej-'~9genomic'%01~jZXWONKJIGC964-*_))
"height": 100,
...
"y": { "value": 0 }, // baseline
"ye": { "value": 25 } // 1/4 of the height
Is this what you were looking for?
Also, just curious since you want to set the 'constant' height of the bars – is actual data, i.e, size_mb, used for other visual channels, like color, in your use case?
Thanks @sehilyi I thought y
and ye
take discrete values and didn't realize they are instead fractional (or %).
Also, just curious since you want to set the 'constant' height of the bars – is actual data, i.e, size_mb, used for other visual channels, like color, in your use case?
I wanted to highlight 3-4 features in a genomic region using overlay
(couldn't use stack
to avoid certain complexity), and I wanted to highlight one of the features with a particular color up to a particular y
value. I couldn't figure it out using y
/ye
and finally ended up using arrow marks instead to highlight the feature; If I ever need to refactor it, I will use your solution :)
Is there a way to provide a constant value to y-axis in the bar chart (and others as well)? For example, in the gallery example of bar chart, is it possible to a set constant value 0.0005 to y instead of reading specifying it from the
data
object?