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 8080297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:22:19+00:00 2026-06-05T16:22:19+00:00

I have some troubles with plotting the figure. I have a file with some

  • 0

I have some troubles with plotting the figure. I have a file with some results computed by application I wrote in c++ and I would like to plot the figure for the computed data.

The problem is that I don’t know the ‘max’ and ‘min’ limit on axis X and axis Y …

I tried:

# -*- coding: utf-8 -*-
#!/usr/bin/env python

import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt

def plot_it(ox, oy, x_label, y_label, filename) :

    fig = plt.figure()
    axis = fig.add_subplot(111)
    plt.xlabel(x_label)
    plt.ylabel(y_label)
    plt.ylim(min(oy),max(oy))
    plt.xlim(min(ox),max(ox))
    axis.plot(ox, oy, color = 'red')
    plt.savefig(filename)
    plt.clf()
    plt.close()

filename = input("Filename (file with data)\n>")
res = []
try :
    with open(filename, 'r') as file :
        for line in file :
            line = line.rstrip('\n')
            res.append(line.split(" "))
except IOError :
    print("IO error")

if len(res) != 0 :

    ox = []
    oy = []

    x_label = str(input("OX label\n>"))
    y_label = str(input("OY label\n>"))

    for i in range(0,len(res)) :
        ox.append(res[i][0])
        oy.append(res[i][1])

    plot_it(ox, oy, x_label, y_label, 'fig_' + str(filename[:len(filename)-4]) + '.png')

Where my file is here: http://pastie.org/private/4rl64ule9ymljmp6g5bfzg (just copy it and save as file.txt)

I got those errors:

Traceback (most recent call last): File “E:/plotter.py”, line 43, in

plot_it(ox, oy, x_label, y_label, ‘fig_’ + str(filename[:len(filename)-4]) + ‘.png’) File “E:/plotter.py”, line
14, in plot_it
plt.ylim(min(oy),max(oy)) File “C:\Python27\lib\site-packages\matplotlib\pyplot.py”, line 1252, in
ylim
ret = ax.set_ylim(*args, **kwargs) File “C:\Python27\lib\site-packages\matplotlib\axes.py”, line 2642, in
set_ylim
bottom, top = mtransforms.nonsingular(bottom, top, increasing=False) File
“C:\Python27\lib\site-packages\matplotlib\transforms.py”, line 2282,
in nonsingular
if (not np.isfinite(vmin)) or (not np.isfinite(vmax)): NotImplementedError: Not implemented for this type

  • 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-06-05T16:22:20+00:00Added an answer on June 5, 2026 at 4:22 pm

    Add:

    plt.ylim(min(oy),max(oy))
    plt.xlim(min(ox),max(ox))
    

    to the second block of code you give, this will set your x and limits to the min/max of your data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some troubles with parsing matrix file. It looks sth like this: #
I have some troubles with getting the data from the website. The website source
I have some troubles while writing logs from log4net to the file. I seem
I have some troubles with receiving data on server side. Here goes the code:
Right now I have some troubles. I'm finding a way to solve one problem.
Especially android-developers :) I have some troubles with application menu which i try to
Greetings! I have some troubles enabling OAuth authentication for my web application running on
I really have some troubles since 1 week ago. I got errors like this
I have some troubles with the application of polymorphism in this example. This question
I have some troubles trying to move data from SQL Server 2000 (SP4) to

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.