Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

No way to resize getImage font #38

Open

Description

@edwinfinch

Hello!

You have a really great library and service here, thank you for that. I'm using it for one of my Telegram bots now. When Telegram sends an image, it is compressed, and therefore a lot of the quality is lost. I find on the Plotly Node.JS library no way to resize the font of the text on the X or Y axis. I also can't put a title on the top of the image. Could you please add support for this?

Thanks!

Activity

  1. etpinard commented on Dec 29, 2015

    @etpinard
    Contributor

    @edwinfinch maybe this https://plot.ly/nodejs/font/ could help you out.

  2. edwinfinch commented on Dec 29, 2015

    @edwinfinch
    Author

    @etpinard That's what I thought, and then I actually gave it a shot and it simply ignores the font option. Looked into the plotly node code myself and it doesn't even send anything from imageOptions except what is put in the examples (type, width, height IIRC).

    What I ended up doing for now is calling .plot() and taking the URL from there, appending an ending onto it to get the PNG file, downloaded that and sent that. Works fine for now, though getImage would be cleaner since I wouldn't have to write my own API for it. And I'm pretty sure getImage is not affected by the API limits (though it may be?), whereas plot is and I reached my 50/day limit pretty darn quick.

  3. etpinard commented on Dec 29, 2015

    @etpinard
    Contributor

    @edwinfinch getImage expect a figure object containing data and layout attributes:

    So starting with:

    var data = [
      {
        x: [0, 1, 2, 3, 4, 5, 6, 7, 8],
        y: [0, 1, 2, 3, 4, 5, 6, 7, 8],
        type: "scatter"
      }
    ];
    
    var layout = {
      title: "Global Font",
      font: {
        family: "Courier New, monospace",
        size: 18,
        color: "#7f7f7f"
      }
    };

    the plot call signature is:

    var graphOptions = {layout: layout, filename: "global-font", fileopt: "overwrite"};
    plotly.plot(data, graphOptions, function (err, msg) {
        console.log(msg);
    });

    while the getImage call signature is:

    var figure = {data: data, layout: layout};
    var imgOpts = {format: 'png', width: 1000, height: 500};
    plotly.getImage(figure, imgOpts, function (error, imageStream) {
        if (error) return console.log (error);
    
        var fileStream = fs.createWriteStream('1.png');
        imageStream.pipe(fileStream);
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions