Code Monkey home page Code Monkey logo

Comments (8)

Jellevanderwerff avatar Jellevanderwerff commented on May 19, 2024

The gaps should be filled up

from thebeat.

Jellevanderwerff avatar Jellevanderwerff commented on May 19, 2024

Was fixed in 9f0b9e4 for thebeat.helpers.plot_single_sequence, but not yet for thebeat.visualization.plot_multiple_sequences. Will take a look later because that's slightly different. The y-axis there is provided as a categorical variable, which matplotlib.pyplot.vlines does not support.

from thebeat.

Jellevanderwerff avatar Jellevanderwerff commented on May 19, 2024

Also, after 9f0b9e4 the lines have different widths. It's difficult to see but compare e.g. these two:

afbeelding

from thebeat.

Jellevanderwerff avatar Jellevanderwerff commented on May 19, 2024

I think this is the way forward:

import thebeat
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.patches as mpatches

# Create sequence
s = thebeat.Sequence([100, 500, 1000] * 50, first_onset=20, name="test")

# Make empty fig and ax
fig, ax = plt.subplots()

# Set title
ax.set_title("Sequence")

# Get final IOI
final_ioi = s.iois[-1] if s.end_with_interval is True else 0

# Set x and y limits
ax.set_ylim(0, 1)
ax.set_xlim(0, s.onsets[-1] + final_ioi)

# Plot onsets as rectangles
for onset in s.onsets:
    rect = mpatches.Rectangle(xy=(onset, 0), height=1, width=np.min(s.iois) / 10, color="blue", fill=True)
    ax.add_patch(rect)

# Remove y tick labels
ax.set_yticklabels([])
ax.set_yticks([])

# Show plot
plt.show()

I am also closing #6, because that is related.

from thebeat.

Jellevanderwerff avatar Jellevanderwerff commented on May 19, 2024

Almost done in 9e23c3d . Solution is a bit hacky for now, that has to be improved in the future.

from thebeat.

Jellevanderwerff avatar Jellevanderwerff commented on May 19, 2024

I'm having trouble reproducing this issue. My observations:

  • It does not seem to depend on the type of matplotlib version used
  • When saving the figure in how originally these sequences were created, there didn't seem to be an issue, even at low dpi (e.g. 100)
  • My guess is that it's a problem with the inline backend of matplotlib, as the first time this issue came to light was in a Jupyter notebook

So:

  • We will revert commits d131cc8 and 9f0b9e4
  • We will not merge the branch better_sequence_plots', but leave it be for a while. Let's see if the problem resurfaces at some point, but I think it was a pretty specific issue.
  • We will take one idea from the new branch, namely another way of renaming the y-axis labels if multiple the same exist (completely unrelated to the pres. issue, here as a reminder). This will be done in a separate commit.

from thebeat.

Jellevanderwerff avatar Jellevanderwerff commented on May 19, 2024

9f0b9e4 reverted in cb76fb9

from thebeat.

Jellevanderwerff avatar Jellevanderwerff commented on May 19, 2024

Closing this issue.

from thebeat.

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.