Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6342867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:19:30+00:00 2026-05-24T20:19:30+00:00

I want to use the plot method of the matplotlib and plot 2 arrays.

  • 0

I want to use the plot method of the matplotlib and plot 2 arrays. The array to be plotted along the x-axis has 1 row and 128 columns [1,128]. The array to be plotted along the y-axis has 14 rows and 128 columns [14,128]. When I try to use the plot method, it returns this message:

ValueError: x and y must have same first dimension

This is the code that I am using to plot it. a and b are the 2 arrays.

line, = plt.plot(b, a, 'bs', markersize=4)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:19:31+00:00Added an answer on May 24, 2026 at 8:19 pm

    You’ve just got your arrays the wrong way around. Transpose them and everything should work.

    >>> from matplotlib import pyplot as plt
    >>> import numpy as np
    >>> x = np.array(range(1,129))
    >>> y = np.random.rand(14,128)
    >>> plt.plot(x, y)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 2286, in plot 
        ret = ax.plot(*args, **kwargs)
      File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 3783, in plot
        for line in self._get_lines(*args, **kwargs):
      File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 317, in _grab_next_args
        for seg in self._plot_args(remaining, kwargs):
      File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 294, in _plot_args
        x, y = self._xy_from_xy(x, y)
      File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 234, in _xy_from_xy
        raise ValueError("x and y must have same first dimension")
    ValueError: x and y must have same first dimension
    >>> plt.plot(x.T, y.T)
    # works
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use core-plot for drawing line graph dynamically. data won't come at
Below is my stored procedure. I want use stored procedure select all row of
I want to use jcharts2d to plot fast updating data. The examples for dynamic
Has anyone managed to use core-plot from wax? I have been trying recently, but
I want to use the 2d plot([x1,x2,x3,x1],[y1,y2,y3,y1]) to draw a triangle in my plot
I want to use the title CO2 emissions in wetlands in a plot in
I want use groovy findAll with my param to filtering closure filterClosure = {
i want use some data from a website with web service. i have a
I have a transaction log file in CSV format that I want use to
I want to use the mouse scrollwheel in my OpenGL GLUT program to zoom

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.