__author__ = 'jgosmann'

from prettyplotlib.utils import remove_chartjunk, maybe_get_ax
from prettyplotlib.colors import set2


def eventplot(*args, **kwargs):
    ax, args, kwargs = maybe_get_ax(*args, **kwargs)
    show_ticks = kwargs.pop('show_ticks', False)

    # FIXME 1d positions
    if len(args) > 0:
        positions = args[0]
    else:
        positions = kwargs['positions']
    kwargs.setdefault('colors', [c + (1.0,) for c in set2[:len(positions)]])

    event_collections = ax.eventplot(*args, **kwargs)
    remove_chartjunk(ax, ['top', 'right'], show_ticks=show_ticks)
    return event_collections

__author__ = 'jgosmann'

from matplotlib.cbook import iterable

from prettyplotlib.utils import remove_chartjunk, maybe_get_ax
from prettyplotlib.colors import set2


def eventplot(*args, **kwargs):
    ax, args, kwargs = maybe_get_ax(*args, **kwargs)
    show_ticks = kwargs.pop('show_ticks', False)

    if len(args) > 0:
        positions = args[0]
    else:
        positions = kwargs['positions']

    if any(iterable(p) for p in positions):
        size = len(positions)
    else:
        size = 1

    kwargs.setdefault('colors', [c + (1.0,) for c in set2[:size]])

    event_collections = ax.eventplot(*args, **kwargs)
    remove_chartjunk(ax, ['top', 'right'], show_ticks=show_ticks)
    return event_collections

Fix eventplot for 1d arguments.
Fix eventplot for 1d arguments.

  __author__ = 'jgosmann'
+ 
+ from matplotlib.cbook import iterable
  
  from prettyplotlib.utils import remove_chartjunk, maybe_get_ax
  from prettyplotlib.colors import set2
  
  
  def eventplot(*args, **kwargs):
      ax, args, kwargs = maybe_get_ax(*args, **kwargs)
      show_ticks = kwargs.pop('show_ticks', False)
  
-     # FIXME 1d positions
      if len(args) > 0:
          positions = args[0]
      else:
          positions = kwargs['positions']
+ 
+     if any(iterable(p) for p in positions):
+         size = len(positions)
+     else:
+         size = 1
+ 
-     kwargs.setdefault('colors', [c + (1.0,) for c in set2[:len(positions)]])
+     kwargs.setdefault('colors', [c + (1.0,) for c in set2[:size]])
  
      event_collections = ax.eventplot(*args, **kwargs)
      remove_chartjunk(ax, ['top', 'right'], show_ticks=show_ticks)
      return event_collections
  
Fix eventplot for 1d arguments.
## Code Before:
__author__ = 'jgosmann'

from prettyplotlib.utils import remove_chartjunk, maybe_get_ax
from prettyplotlib.colors import set2


def eventplot(*args, **kwargs):
    ax, args, kwargs = maybe_get_ax(*args, **kwargs)
    show_ticks = kwargs.pop('show_ticks', False)

    # FIXME 1d positions
    if len(args) > 0:
        positions = args[0]
    else:
        positions = kwargs['positions']
    kwargs.setdefault('colors', [c + (1.0,) for c in set2[:len(positions)]])

    event_collections = ax.eventplot(*args, **kwargs)
    remove_chartjunk(ax, ['top', 'right'], show_ticks=show_ticks)
    return event_collections

## Instruction:
Fix eventplot for 1d arguments.
## Code After:
__author__ = 'jgosmann'

from matplotlib.cbook import iterable

from prettyplotlib.utils import remove_chartjunk, maybe_get_ax
from prettyplotlib.colors import set2


def eventplot(*args, **kwargs):
    ax, args, kwargs = maybe_get_ax(*args, **kwargs)
    show_ticks = kwargs.pop('show_ticks', False)

    if len(args) > 0:
        positions = args[0]
    else:
        positions = kwargs['positions']

    if any(iterable(p) for p in positions):
        size = len(positions)
    else:
        size = 1

    kwargs.setdefault('colors', [c + (1.0,) for c in set2[:size]])

    event_collections = ax.eventplot(*args, **kwargs)
    remove_chartjunk(ax, ['top', 'right'], show_ticks=show_ticks)
    return event_collections
