1
votes

I keep getting the error TypeError: from_bounds() takes 4 positional arguments but 6 were given when trying to insert a Python Visualization in Power BI. Though it seems that Matplotlib is the problem here, I don't know if that is the root cause.

My system:

Windows 7, 64 bit
Power BI august 2018
Python 3.6.6.0
Matplotlib 2.2.2
Pandas 0.23.4

I can't be 100% sure that this is in fact a version problem, but I can't think of anything else because I'm using the same dataset that was successfully used in the post What is the best data format for a time series in a Python Visualization in Power BI?.

Data:

Date,Value
2017-01-12,1
2017-01-13,4
2017-01-14,2
2017-01-15,4
2017-01-16,2
2017-01-17,2
2017-01-18,2
2017-01-19,5
2017-01-20,5
2017-01-21,5
2017-01-22,5
2017-01-23,6
2017-01-24,3
2017-01-25,6
2017-01-26,6
2017-01-27,5
2017-01-28,8
2017-01-29,4
2017-01-30,2

Code:

import matplotlib.pyplot as plt
plt.plot(dataset['Date'], dataset['Value'])
plt.show()

Error message screenshot:

enter image description here

Edit 1 - The complete error message:

Feedback Type: Frown (Error)

Timestamp: 2018-08-15T09:58:44.0322850Z

Local Time: 2018-08-15T11:58:44.0322850+02:00

Session ID: 85df81af-81bb-4f82-a7f4-062b315cb370

Release: August, 2018

Product Version: 2.61.5192.601 (18.08) (x64)

Error Message: Python script error. Traceback (most recent call last): File "PythonScriptWrapper.PY", line 6, in matplotlib.pyplot.figure(figsize=(3,75,3,52777777777778)) File "C:\Users\userinfo\AppData\Local\Continuum\Anaconda3\lib\site-packages\matplotlib\pyplot.py", line 548, in figure **kwargs) File "C:\Users\userinfo\AppData\Local\Continuum\Anaconda3\lib\site-packages\matplotlib\backend_bases.py", line 160, in new_figure_manager fig = fig_cls(*args, **kwargs) File "C:\Users\userinfo\AppData\Local\Continuum\Anaconda3\lib\site-packages\matplotlib\figure.py", line 361, in init self.bbox_inches = Bbox.from_bounds(0, 0, *figsize) TypeError: from_bounds() takes 4 positional arguments but 6 were given

OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1 (x64 nb-NO)

CLR Version: 4.7 or later [Release Number = 461310]

Peak Virtual Memory: 4.16 GB

Private Memory: 398 MB

Peak Working Set: 532 MB

IE Version: 11.0.9600.19035

User ID: IDnumber

Workbook Package Info: 1* - nb-NO, Query Groups: 0, fastCombine: Enabled, runBackgroundAnalysis: True.

Telemetry Enabled: True

Model Default Mode: Import

Snapshot Trace Logs: C:\Users\userinfo\AppData\Local\Microsoft\Power BI Desktop\FrownSnapShot1416353677.zip

Performance Trace Logs: C:\Users\userinfo\AppData\Local\Microsoft\Power BI Desktop\PerformanceTraces.zip

Enabled Preview Features: PBI_PythonSupportEnabled

Disabled Preview Features: PBI_shapeMapVisualEnabled PBI_newFromWeb PBI_SpanishLinguisticsEnabled CustomConnectors PBI_variationUIChange PBI_canvasTooltips PBI_showIncrementalRefreshPolicy PBI_compositeModels PBI_DB2DQ

Disabled DirectQuery Options: PBI_DirectQuery_Unrestricted TreatHanaAsRelationalSource

Cloud: GlobalCloud

DPI Scale: 100%

Supported Services: Power BI

Formulas:

section Section1;

shared timeseries = let Source = Csv.Document(File.Contents("C:\data\timeseries.csv"),[Delimiter=",", Columns=2, Encoding=1252, QuoteStyle=QuoteStyle.None]), #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]), #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Date", type date}, {"Value", Int64.Type}}) in #"Changed Type";

1
Can you Copy Details and post the full error?Foxan Ng
I added it just now.vestland

1 Answers

3
votes

OK now it's obvious where the error comes from.

In the line (which Power BI generates on the fly):

matplotlib.pyplot.figure(figsize=(5,87473572938689,6,87403100775194))

It grabs the dimensions in your locale (which in this case use ',' as decimal point) and passes it to figsize.

While figsize accepts a tuple of (width, height) in inches as input, 5,87473572938689,6,87403100775194 is treated as 4 arguments, instead of 2, which causes the error.


So to work around this, you can either explicitly pass figsize (using values with . as decimal point) to plt.figure, i.e.:

import matplotlib.pyplot as plt
plt.figure(figsize=(5.874,6.874))
plt.plot(dataset['Date'], dataset['Value'])
plt.show()

Or change the locale in Power BI to one which use . as decimal points instead of ,.