Skip to content

Table exports with a long line in PDFs #1280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
priyatharsan opened this issue Nov 20, 2018 · 8 comments
Closed

Table exports with a long line in PDFs #1280

priyatharsan opened this issue Nov 20, 2018 · 8 comments

Comments

@priyatharsan
Copy link
Contributor

priyatharsan commented Nov 20, 2018

related to: plotly/orca#147 and https://github.com/plotly/streambed/issues/11618

The PDF exports display line in the following environments:

  • Windows 10 / Chrome viewer
  • Windows 10 / Adobe-reader
  • MacOS10.13 / Chrome70

Example :

import plotly.plotly as py
import plotly.graph_objs as go

import pandas as pd
import colorlover as cl

colors = cl.scales['5']['seq']['Blues']
data = {'Year' : [2010, 2011, 2012, 2013, 2014],
        'Color' : colors}
df = pd.DataFrame(data)


trace0 = go.Table(
  header = dict(
    values = ["Color", "<b>YEAR</b>"],
    line = dict(color = 'white'),
    fill = dict(color = 'white'),
    align = ['center'],
    font = dict(color = 'black', size = 12)
  ),
  cells = dict(
    values = [df.Color, df.Year],
    line = dict(color = [df.Color]),
    fill = dict(color = [df.Color]),
    align = 'center',
    font = dict(color = 'black', size = 11)
    ))

data = [trace0]

py.iplot(data, filename = "row variable color")

capture

Please note that this behavior is happening only when saving via Python API call and exporting via the plot's view page at plot.ly. I don't see the line when saving/exporting via Chart studio.

@jonmmease
Copy link
Contributor

Could you explain how the PDF is being generated? It looks like the code above uploads the plot to Chart Studio but doesn't produce a pdf. Are you using plotly.io.write_image?

@priyatharsan
Copy link
Contributor Author

priyatharsan commented Nov 21, 2018

Apologies for not being clear. I'm exporting from the plot's view page: https://plot.ly/~priyatharsan/977/

screenshot 21

@jonmmease
Copy link
Contributor

No problem. So at that point, the figure has moved out of plotly.py and is being stored in JSON form on chart studio cloud. Could you try to identify a difference in the JSON representation between the figure that exports properly and the one that doesn't?

@priyatharsan
Copy link
Contributor Author

Here is the plot that exports with a line: https://plot.ly/~priyatharsan/977/
and no line: https://plot.ly/~priyatharsan/986/
The only differences I can find are:
cells.fill.colorsrc, cells.line.colorsrc, cells.valuessrc, header.alignsrc, header.alignsrc, and uid

@jonmmease
Copy link
Contributor

jonmmease commented Nov 22, 2018

If I understand correctly, here's the JSON of the figure that exports with the line:

{
  "data": [
    {
      "header": {
        "line": {
          "color": "white"
        },
        "font": {
          "color": "black",
          "size": 12
        },
        "values": [
          "Color",
          "<b>YEAR</b>"
        ],
        "align": [
          "center"
        ],
        "fill": {
          "color": "white"
        }
      },
      "cells": {
        "align": "center",
        "font": {
          "color": "black",
          "size": 11
        },
        "values": [
          [
            "rgb(239,243,255)",
            "rgb(189,215,231)",
            "rgb(107,174,214)",
            "rgb(49,130,189)",
            "rgb(8,81,156)"
          ],
          [
            2010,
            2011,
            2012,
            2013,
            2014
          ]
        ],
        "line": {
          "color": [
            [
              "rgb(239,243,255)",
              "rgb(189,215,231)",
              "rgb(107,174,214)",
              "rgb(49,130,189)",
              "rgb(8,81,156)"
            ]
          ]
        },
        "fill": {
          "color": [
            [
              "rgb(239,243,255)",
              "rgb(189,215,231)",
              "rgb(107,174,214)",
              "rgb(49,130,189)",
              "rgb(8,81,156)"
            ]
          ]
        }
      },
      "type": "table",
      "uid": "311d89d8-2dac-4496-ac18-728c6af0f710"
    }
  ]
}

Here's the pdf I get when exporting this to a PDF using plotly.py and orca directly with plotly.io.write_image on plotly.py 3.4.1 (not through chart studio). I don't see a line here in the Chrome 70 PDF reader on MacOs.

table.pdf

Do you see a line here?

Also, I noticed in plotly/orca#147 that @etpinard asked

Can someone confirm that they are all using [email protected]?

and you answered by referencing the version specified in the plotly.py repo. This is the plotly.js version that is used when exporting to an image locally (using plotly.py's plotly.io.write_image function), but this version is not relevant if you're exporting to a PDF through chart studio. So perhaps that environment hasn't been updated yet?

@etpinard
Copy link
Contributor

@priyatharsan I'll close this ticket

The latest version of orca, plotly.py and plotly.js are able to export that table graph w/o the erroneous line

@priyatharsan
Copy link
Contributor Author

priyatharsan commented Nov 22, 2018

Do you see a line here?

@jonmmease No I don't see any line.

this version is not relevant if you're exporting to a PDF through chart studio.

Apologies for the confusion and it makes more sense now as when I tried with plotly.py's plotly.io.write_image I don't see any line so this has something to do with the Chart Studio itself. Thank you for clarifying this.

@etpinard Thank you for the update I will follow-up with issue's status at https://github.com/plotly/streambed/issues/11618

@vishalsharma3003
Copy link

I had the same problem and there is not much information provided. I don't know the exact reason why the erroneous line is there in these graphs but I have a workaround for this.
Try setting the background color of the graph and you'll notice that the line is aligned with the background so I adjusted the margins and put the right margin to zero and the problem was resolved.

layout(margin = list(r = 0, pad = 0))

Before:
image

After:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants