10000 (issue 900): implemented Range.add_plot() and add_table() by alixdamman · Pull Request #926 · larray-project/larray · GitHub
[go: up one dir, main page]

Skip to content

(issue 900): implemented Range.add_plot() and add_table() #926

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

Open
8000 wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
renamed make_plot() as add_plot()
  • Loading branch information
alixdamman committed Jan 18, 2022
commit a17554498f2cc9975a061a68f9d182c8430ca061
2 changes: 1 addition & 1 deletion doc/source/changes/version_0_33.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Miscellaneous improvements

* implemented :py:obj:`Axis.min()` and :py:obj:`Axis.max()` methods (closes :issue:`874`).

* implemented the :py:obj:`Range.make_plot()` method that allows to create graphs when using
* implemented the :py:obj:`Range.add_plot()` method that allows to create graphs when using
`open_excel()` (closes :issue:`900`).

Fixes
Expand Down
10 changes: 5 additions & 5 deletions larray/inout/xw_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,10 +620,10 @@ def load(self, header=True, convert_float=True, nb_axes=None, index_col=None, fi
else:
return Array(list_data)

def make_plot(self, data_source: str, width: int=427, height: int=230, title: str=None, template: str=None,
min_y: Union[int, float]=None, max_y: Union[int, float]=None,
xticks_spacing: Union[int, float]=None, customize_func: Callable=None,
customize_kwargs: Dict[str, str]=None) -> Any:
def add_plot(self, data_source: str, width: int=427, height: int=230, title: str=None, template: str=None,
min_y: Union[int, float]=None, max_y: Union[int, float]=None,
xticks_spacing: Union[int, float]=None, customize_func: Callable=None,
customize_kwargs: Dict[str, str]=None) -> Any:
from xlwings.constants import LegendPosition, ChartType, RowCol, E5BE AxisType, Constants, Direction
if customize_func is not None and not callable(customize_func):
raise TypeError(f"Expected a function for the argument 'customize_func'. "
Expand Down Expand Up @@ -818,7 +818,7 @@ def open_excel(filepath=None, overwrite_file=False, visible=None, silent=None, a
>>> # to create a new Excel file, argument overwrite_file must be set to True
>>> with open_excel('excel_file.xlsx', overwrite_file=True) as wb: # doctest: +SKIP
... wb['arr'] = arr.dump()
... wb['arr']['A1'].make_plot('A6', title='simple graph')
... wb['arr']['A6'].add_plot('A1', title='simple graph')
... wb.save()

read array from an Excel file
Expand Down
8 changes: 4 additions & 4 deletions larray/tests/test_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,18 +251,18 @@ def test_repr(self):


@needs_xlwings
def test_make_plot():
def test_add_plot():
demo = load_example_data('demography_eurostat')
population = demo.population
population_be = population['Belgium']
population_be_nan = population_be.astype(float)
population_be_nan[2013] = nan

with open_excel(filepath='test_make_plot.xlsx', visible=False, overwrite_file=True) as wb:
with open_excel(filepath='test_add_plot.xlsx', visible=False, overwrite_file=True) as wb:
sheet = wb[0]
sheet["B2"] = population_be.dump()
sheet["B8"].make_plot("B2")
sheet["L8"].make_plot("B2:F4")
sheet["B8"].add_plot("B2")
sheet["L8"].add_plot("B2:F4")
wb.save()


Expand Down
0