Skip to content
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

Remove autoscale view call from plot_state_hinton #4811

Merged
merged 5 commits into from
Dec 3, 2020
Merged
Changes from 4 commits
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
21 changes: 10 additions & 11 deletions qiskit/visualization/state_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,16 @@ def plot_state_hinton(state, title='', figsize=None, ax_real=None, ax_imag=None,
for (x, y), w in np.ndenumerate(datareal):
color = 'white' if w > 0 else 'black'
size = np.sqrt(np.abs(w) / max_weight)
rect = plt.Rectangle([x - size / 2, y - size / 2], size, size,
rect = plt.Rectangle([0.5 + x - size / 2, 0.5 + y - size / 2], size, size,
facecolor=color, edgecolor=color)
ax1.add_patch(rect)

ax1.set_xticks(np.arange(0, lx+0.5, 1))
ax1.set_yticks(np.arange(0, ly+0.5, 1))
row_names.append('')
ax1.set_xticks(0.5 + np.arange(lx))
ax1.set_yticks(0.5 + np.arange(ly))
ax1.set_xlim([0, lx])
ax1.set_ylim([ly, 0])
ax1.set_yticklabels(row_names, fontsize=14)
column_names.append('')
ax1.set_xticklabels(column_names, fontsize=14, rotation=90)
ax1.autoscale_view()
ax1.invert_yaxis()
ax1.set_title('Re[$\\rho$]', fontsize=14)
# Imaginary
Expand All @@ -163,16 +162,16 @@ def plot_state_hinton(state, title='', figsize=None, ax_real=None, ax_imag=None,
for (x, y), w in np.ndenumerate(dataimag):
color = 'white' if w > 0 else 'black'
size = np.sqrt(np.abs(w) / max_weight)
rect = plt.Rectangle([x - size / 2, y - size / 2], size, size,
rect = plt.Rectangle([0.5 + x - size / 2, 0.5 + y - size / 2], size, size,
facecolor=color, edgecolor=color)
ax2.add_patch(rect)

ax2.set_xticks(np.arange(0, lx+0.5, 1))
ax2.set_yticks(np.arange(0, ly+0.5, 1))
ax2.set_xticks(0.5 + np.arange(lx))
ax2.set_yticks(0.5 + np.arange(ly))
ax1.set_xlim([0, lx])
ax1.set_ylim([ly, 0])
ax2.set_yticklabels(row_names, fontsize=14)
ax2.set_xticklabels(column_names, fontsize=14, rotation=90)

ax2.autoscale_view()
ax2.invert_yaxis()
ax2.set_title('Im[$\\rho$]', fontsize=14)
if title:
Expand Down