<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Bins Mark
This Mark is essentially the same as the Hist Mark from a user point of view, but is actually a Bars instance that bins sample data.
The difference with Hist is that the binning is done in the backend, so it will work better for large data as it does not have to ship the whole data back and forth to the frontend.
Step1:  Give the Hist mark the data you want to perform as the sample argument, and also give 'x' and 'y' scales.
Step2:  The midpoints of the resulting bins and their number of elements can be recovered via the read-only traits x and y
Step3:  Tuning the bins
Under the hood, the Bins mark is really a Bars mark, with some additional magic to control the binning. The data in sample is binned into equal-width bins. The parameters controlling the binning are the following traits
Step4:  Histogram Styling
The styling of Hist is identical to the one of Bars
<ASSISTANT_TASK:>
Python Code:
# Create a sample of Gaussian draws
np.random.seed(0)
x_data = np.random.randn(1000)
Explanation: Bins Mark
This Mark is essentially the same as the Hist Mark from a user point of view, but is actually a Bars instance that bins sample data.
The difference with Hist is that the binning is done in the backend, so it will work better for large data as it does not have to ship the whole data back and forth to the frontend.
End of explanation
fig = plt.figure(padding_y=0)
hist = plt.bin(x_data, padding=0)
fig
Explanation: Give the Hist mark the data you want to perform as the sample argument, and also give 'x' and 'y' scales.
End of explanation
hist.x, hist.y
Explanation: The midpoints of the resulting bins and their number of elements can be recovered via the read-only traits x and y:
End of explanation
fig = plt.figure(padding_y=0)
hist = plt.bin(x_data, padding=0)
fig
# Changing the number of bins
hist.bins = "sqrt"
# Changing the range
hist.min = 0
Explanation: Tuning the bins
Under the hood, the Bins mark is really a Bars mark, with some additional magic to control the binning. The data in sample is binned into equal-width bins. The parameters controlling the binning are the following traits:
bins sets the number of bins. It is either a fixed integer (10 by default), or the name of a method to determine the number of bins in a smart way ('auto', 'fd', 'doane', 'scott', 'rice', 'sturges' or 'sqrt').
min and max set the range of the data (sample) to be binned
density, if set to True, normalizes the heights of the bars.
For more information, see the documentation of numpy's histogram
End of explanation
# Normalizing the count
fig = plt.figure(padding_y=0)
hist = plt.bin(x_data, density=True)
fig
# changing the color
hist.colors = ["orangered"]
# stroke and opacity update
hist.stroke = "orange"
hist.opacities = [0.5] * len(hist.x)
# Laying the histogram on its side
hist.orientation = "horizontal"
fig.axes[0].orientation = "vertical"
fig.axes[1].orientation = "horizontal"
Explanation: Histogram Styling
The styling of Hist is identical to the one of Bars
End of explanation
<END_TASK>