Skip to content

Should plot with options in the order given #15

Open
@dreammaker

Description

@dreammaker

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions