|
5 | 5 | import numpy as np |
6 | 6 | import pytest |
7 | 7 |
|
| 8 | +from pandas.errors import PandasFutureWarning |
8 | 9 | import pandas.util._test_decorators as td |
9 | 10 |
|
10 | 11 | from pandas import ( |
@@ -864,34 +865,45 @@ def test_plot_bar_label_count_expected_success(): |
864 | 865 | [(30, 10, 10, 10), (20, 20, 20, 20), (10, 30, 30, 10)], columns=list("ABCD") |
865 | 866 | ) |
866 | 867 | df.plot(subplots=[("A", "B", "D")], kind="bar", title=["A&B&D", "C"]) |
867 | | - @pytest.mark.filterwarnings("default") |
868 | | - def test_change_scatter_markersize_rcparams(self): |
869 | | - # GH 54204 |
870 | | - # Ensure proper use of lines.markersize to style pandas scatter |
871 | | - # plots like matplotlib does. |
872 | | - # Will raise deprecation warnings. |
873 | | - df = DataFrame(data={"x": [1, 2, 3], "y": [1, 2, 3]}) |
874 | | - |
875 | | - pandas_default = df.plot.scatter( |
| 868 | + |
| 869 | + |
| 870 | +def testhhh_change_scatter_markersize_future_warning(): |
| 871 | + # GH 54204 |
| 872 | + # Will raise FutureWarning if s not provided to df.plot.scatter |
| 873 | + df = DataFrame(data={"x": [1, 2, 3], "y": [1, 2, 3]}) |
| 874 | + with tm.assert_produces_warning(PandasFutureWarning): |
| 875 | + pandas_default_without_rcparams = df.plot.scatter( |
876 | 876 | x="x", y="y", title="pandas scatter, default rc marker size" |
877 | 877 | ) |
| 878 | + # Verify that pandas still defaults to 20 |
| 879 | + assert pandas_default_without_rcparams.collections[0].get_sizes()[0] == 20 |
878 | 880 |
|
879 | | - mpl_default = mpl.pyplot.scatter(df["x"], df["y"]) |
880 | 881 |
|
881 | | - # verify that pandas and matplotlib scatter |
882 | | - # default marker size are the same (s = 6^2 = 36) |
883 | | - assert ( |
884 | | - pandas_default.collections[0].get_sizes()[0] == mpl_default.get_sizes()[0] |
| 882 | +@pytest.mark.filterwarnings( |
| 883 | + "ignore:The default of s=20 will be changed:pandas.errors.PandasFutureWarning" |
| 884 | +) |
| 885 | +def testhhh_scatter_markersize_same_default_with_rcparams(): |
| 886 | + # GH 54204 |
| 887 | + # Ensure default markersize is still 20 if no rcparams |
| 888 | + df = DataFrame(data={"x": [1, 2, 3], "y": [1, 2, 3]}) |
| 889 | + with mpl.rc_context({"lines.markersize": 10}): |
| 890 | + pandas_default_with_rcparams = df.plot.scatter( |
| 891 | + x="x", y="y", title="pandas scatter, changed rc marker size" |
885 | 892 | ) |
| 893 | + # Verify that pandas default markersize is still 20 with rc_params |
| 894 | + assert pandas_default_with_rcparams.collections[0].get_sizes()[0] == 20 |
886 | 895 |
|
887 | | - with mpl.rc_context({"lines.markersize": 10}): |
888 | | - pandas_changed = df.plot.scatter( |
889 | | - x="x", y="y", title="pandas scatter, changed rc marker size" |
890 | | - ) |
891 | | - mpl_changed = mpl.pyplot.scatter(df["x"], df["y"]) |
892 | 896 |
|
893 | | - # verify that pandas and matplotlib scatter |
894 | | - # changed marker size are the same (s = 10^2 = 100) |
895 | | - assert ( |
896 | | - pandas_changed.collections[0].get_sizes()[0] == mpl_changed.get_sizes()[0] |
897 | | - ) |
| 897 | +@pytest.mark.filterwarnings( |
| 898 | + "ignore:The default of s=20 will be changed:pandas.errors.PandasFutureWarning" |
| 899 | +) |
| 900 | +def testhhh_scatter_markersize_same_default_without_rcparams(): |
| 901 | + # GH 54204 |
| 902 | + # Ensure default markersize is still 20 if no rcparams |
| 903 | + df = DataFrame(data={"x": [1, 2, 3], "y": [1, 2, 3]}) |
| 904 | + |
| 905 | + pandas_default_with_rcparams = df.plot.scatter( |
| 906 | + x="x", y="y", title="pandas scatter, changed rc marker size" |
| 907 | + ) |
| 908 | + # Verify that pandas default markersize is still 20 without rc_params |
| 909 | + assert pandas_default_with_rcparams.collections[0].get_sizes()[0] == 20 |
0 commit comments