Code Monkey home page Code Monkey logo

Comments (8)

hcarty avatar hcarty commented on May 13, 2024 1

This is possible in PLplot using either Plplot.Plot.axes or Plplot.plslabelfunc. Owl may need some modification to integrate this properly but the underlying support is there.

from owl.

zoggy avatar zoggy commented on May 13, 2024

Thanks ! Indeed the underlying structure is abstract in Owl :-/

from owl.

ryanrhymes avatar ryanrhymes commented on May 13, 2024

@zoggy Definitely an important function, I added it. I hope the following code will work for you for the time being. It is only in the master branch and not in the OPAM release yet.

let x = Vec.sequential 4;;
let y = Vec.uniform 4;;
let h = Plot.create "labeltest.pdf";;
Plot.plot ~h x y;;
Plot.set_xticklabels h [0.,"Jan"; 1.,"Feb"; 2.,"Mar"; 3.,"Apr"];;
Plot.output h;;

from owl.

ryanrhymes avatar ryanrhymes commented on May 13, 2024

Plot module is actually quite straightforward. All the information of a page is saved in a record (of type page). All the operations you have done on a page will be cached in a list page.plots. Whenever you call output function, Plot module will call _initialise, _prepare_page, _finalise these three functions to actually finish "drawing" your plot then output.

from owl.

zoggy avatar zoggy commented on May 13, 2024

Thanks. I had to opam pin to master branch of eigen too but no problem.

Plot.set_xticklabels works, except that some labels do not appear; I though this was a question of missing space and reduced the font size, but no. Is there something more to do ?

from owl.

ryanrhymes avatar ryanrhymes commented on May 13, 2024

I guess this is because currently Owl only draws at the major ticks, the reason is plslabelfunc calls the callback function whenever it encounters the major ticks. @hcarty should know more about how to customise the ticks in Plplot.

from owl.

hcarty avatar hcarty commented on May 13, 2024

First an API suggestion: maybe the Plot.set_*ticklabels function should take a list of (value : float, label : string) tuples? That will guarantee that a user can't accidentally pass in lists of mismatched lengths.

Second, regarding tick spacing and labeling - there is detection logic in the C core of PLplot which handles this. I don't recall the details - it's been a while since I hacked on that code - but it is possible to manually specify the major (plsmaj) and minor (plsmin) tick spacing. IIRC all major ticks are labeled by default.

For for your months example @zoggy, if no sub-monthly variability is shown, the major tick spacing would be 1.0 and minor ticks would be hidden.

from owl.

ryanrhymes avatar ryanrhymes commented on May 13, 2024

The API suggestion is really nice. I have changed it.

from owl.

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.