Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Potential issue with small numbers in loglog plot#446

Unanswered
williamdwarke asked this question inGeneral
Discussion options

Hi all, I'm posting this in Discussions as opposed to Issues because I'm not actually sure if I'm doing something wrong. I'm trying to plot a line of slope 2 in log-log space, with x-values ranging from 1e-8 to 1e0. However, the matplot loglog plotter seems to be throwing out quite a few of the points, namely, those with y-values less than 1e-10. (For reference, the first 100 or so y-values range between 1e-16 and 1e-10). I'd really appreciate it if somebody could take a look and let me know if I've done something wrong, or if I should submit this as a bug report. I've included a minimal working version of my code, as well as the plot it produces. Thank you!

#include <iostream>#include <matplot/matplot.h>int main(int argc, char **argv) {    // Number of data points    int N = 1000;    // Generate N logspaced X values between 10^-8 and 10^0    double start = -8;    double end = 0;    std::vector<double> t = matplot::logspace(start, end, N);    // Y values (slope 2 in log space)    std::vector<double> log_slope_2(N);    // Compute log slope 2 line    for (int i = 0; i < N; i++) {        log_slope_2[i] = std::pow(10, 2*log10(t[i]));    }        // Uncomment to print points to command line    // for (int i = 0; i < N; i++) {    //     std::cout << "(" << t[i] << ", " << log_slope_2[i] << "), ";    // }    // std::cout << std::endl;    auto plt = matplot::loglog(t, log_slope_2);    plt->line_width(2);        matplot::show();    return 0;}

plot

You must be logged in to vote

Replies: 0 comments

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Labels
None yet
1 participant
@williamdwarke

[8]ページ先頭

©2009-2025 Movatter.jp