Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should plot with options in the order given #15

Open
dreammaker opened this issue Sep 26, 2017 · 0 comments
Open

Should plot with options in the order given #15

dreammaker opened this issue Sep 26, 2017 · 0 comments

Comments

@dreammaker
Copy link

Once I worked around #14, I discovered many problems. One of them was that my plot options were not being used in the correct order.

Since options are specified with a Ruby Hash, the simplest way that I can think of to specify an order of the options would be to simply use the native order of the input Hash. Ever since Ruby 1.9, iteration order of Hashes is insertion order.

As I dug deeper, I noticed that option order is specifically being changed by GnuplotRB::Dataset::OPTION_ORDER. It's great that I found out that I can change this constant to fix my issues, but the underlying problem remains. If I'm using options that GnuplotRB doesn't specifically know about and special-case, there's no way for me to plot without mucking in the library.

At first, I thought this change would be as simple as switching the #sort_by call to a stable sort. But it seems like the root cause runs deeper. GnuplotRB is converting the Hash options to a Hamster::Hash. Unlike Ruby's built-in Hash, Hamster::Hash doesn't preserve order.

Unfortunately, Hamster doesn't provide an OrderedHash. My first question is, what's the reason for using Hamster::Hash in favor of the built-in Hash?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant