Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

numpy array not accepted for log scaled minor ticks #8023

Copy link
Copy link
Closed
@breedlun

Description

@breedlun
Issue body actions

If I have a log scaled axis, I get an error when I try to specify minor tick marks using a numpy array. The issue does not occur when I use a list instead of a numpy array.

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 2, 50)
y = np.exp(3*x)
plt.plot(x,y)
ax = plt.gca()
minor_ticks = np.array([2,3,4])
ax.set_yscale('log', basey = 10.0, subsy = list(minor_ticks))
ax.set_yscale('log', basey = 10.0, subsy = minor_ticks)

Actual outcome

  File "/Users/Ben/Desktop/test.py", line 21, in <module>
    ax.set_yscale('log', basey = 10.0, subsy = minor_ticks)
  File "/Users/Ben/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/axes/_base.py", line 3224, in set_yscale
    ax.yaxis._set_scale(value, **kwargs)
  File "/Users/Ben/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/axis.py", line 710, in _set_scale
    self._scale.set_default_locators_and_formatters(self)
  File "/Users/Ben/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/scale.py", line 254, in set_default_locators_and_formatters
    labelOnlyBase=bool(self.subs)))
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Expected outcome

This code is expected to run without any errors. I believe it used to run in matplotlib v1.5.1, but I think that used an earlier version of numpy. At that time, I think numpy printed a warning message to the screen.

Matplotlib version

  • Matplotlib 2.0.0, Python 2.7.6, OSX
  • Matplotlib installed via Enthought Canopy

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.