Coder Social home page Coder Social logo

Comments (4)

Atrebas avatar Atrebas commented on June 2, 2024 2

Question 1:
You have to pass the order explicitly in xlim. See #206.

library(rbokeh)
# total yield per variety
figure(xlim = levels(lattice::barley$variety)) %>%
  ly_bar(variety, yield, data = lattice::barley, hover = TRUE) %>%
  theme_axis("x", major_label_orientation = 90)

Question 2:
Maybe a problem of version. I don't have the issue with rbokeh_0.5.0.

from rbokeh.

Atrebas avatar Atrebas commented on June 2, 2024 1

I thought my answer would be enough to guide you. Instead of using the levels as above, you just have to provide the order you want. How to compute this order is a general R question.
Below is an an example, using data.table for convenience.

library(data.table)
library(rbokeh)

barley    <- setDT(lattice::barley)
varieties <- barley[, sum(yield), by = variety][
                    order(-V1), as.character(variety)]

# total yield per variety
figure(xlim = varieties) %>%
  ly_bar(variety, yield, data = barley, hover = TRUE) %>%
  theme_axis("x", major_label_orientation = 90)

from rbokeh.

yiugn avatar yiugn commented on June 2, 2024

Thank you Atrebas, your comment was helpful, but what I want is to order x axis by y axis value in decreasing order.
For example, the first x axis data should be Trebi, Wisconsin No.38, because they have the greatest yield, and next No.457, and No.462 ...... and so on, like below

image

How can I do this?

from rbokeh.

yiugn avatar yiugn commented on June 2, 2024

Thank you Atrebas, I've got a solution thanks to your help.
I simply converted columns to factors and set it xlim.
Now it works well!

from rbokeh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.