Jens
October 21, 2024, 10:06am
1
Hello,
the following minimal code
t=linspace(0,10*%pi,200);
subplot(1,2,1)
param3d(cos(t),sin(t),t/20)
ax1=gca();
ax1.isoview='on';
subplot(1,2,2)
param3d(cos(t),sin(t),t/20)
ax2=gca();
ax2.isoview='on';
generates two identical subplots. How can I replace the repetition of the param3d just by copying ax1 into subplot(1,2,2)?
Regards, Jens
Hello,
In fact Scilab can copy only entities which are descendents of Axes and cannot copy Axes themselves (maybe we can work on that, feel free to open an issue). In your case it takes far more lines to set properties of the second Axes than your actual code:
t=linspace(0,10*%pi,200);
subplot(1,2,1)
param3d(cos(t),sin(t),t/20)
h=gce();
ax1=gca();
ax1.isoview='on';
subplot(1,2,2)
ax2=gca();
ax2.isoview='on';
ax2.data_bounds=ax1.data_bounds;
ax2.view=ax1.view;
ax2.axes_visible=ax1.axes_visible;
ax2.rotation_angles=ax1.rotation_angles;
ax2.box=ax1.box;
copy(h,ax2)
Jens
October 21, 2024, 2:25pm
3
Thanks a lot! As a workaround I will simulate subplots by separate figures positioned properly across the screen. That will work fine.
Hi,
out of curiosity I thought it might be possible to define a function that copies all entites from one axis handle to another one.
Turns out: possible, but if it is useful and generally applicable ?
Not so sure…but anyways…
Note: I am not sure, why the code block is separated in between…
function axis_handle_out = copyAxisEntities(axis_handle_in, axis_handle_out)
// input: source axis hande
// destination axis handle as it is after creation
//
// output: destination axis handle with copies of input axis handle entities
axis_handle_out.visible = axis_handle_in.visible
axis_handle_out.axes_visible = axis_handle_in.axes_visible
axis_handle_out.axes_reverse = axis_handle_in.axes_reverse
axis_handle_out.grid = axis_handle_in.grid
axis_handle_out.grid_position = axis_handle_in.grid_position
axis_handle_out.grid_thickness = axis_handle_in.grid_thickness
axis_handle_out.grid_style = axis_handle_in.grid_style
axis_handle_out.x_location = axis_handle_in.x_location
axis_handle_out.y_location = axis_handle_in.y_location
// title entities
axis_handle_out.title.visible = axis_handle_in.title.visible
axis_handle_out.title.text = axis_handle_in.title.text
axis_handle_out.title.font_foreground = axis_handle_in.title.font_foreground
axis_handle_out.title.foreground = axis_handle_in.title.foreground
axis_handle_out.title.background = axis_handle_in.title.background
axis_handle_out.title.fill_mode = axis_handle_in.title.fill_mode
axis_handle_out.title.font_style = axis_handle_in.title.font_style
axis_handle_out.title.font_size = axis_handle_in.title.font_size
axis_handle_out.title.fractional_font = axis_handle_in.title.fractional_font
axis_handle_out.title.font_angle = axis_handle_in.title.font_angle
axis_handle_out.title.auto_position = axis_handle_in.title.auto_position
// do not copy, otherwise output title seems to be placed relative to input axis (?)
// axis_handle_out.title.position = axis_handle_in.title.position
axis_handle_out.title.auto_rotation = axis_handle_in.title.auto_rotation
axis_handle_out.title.user_data = axis_handle_in.title.user_data
axis_handle_out.title.tag = axis_handle_in.title.tag
// x_label entities
axis_handle_out.x_label.visible = axis_handle_in.x_label.visible
axis_handle_out.x_label.text = axis_handle_in.x_label.text
axis_handle_out.x_label.font_foreground = axis_handle_in.x_label.font_foreground
axis_handle_out.x_label.foreground = axis_handle_in.x_label.foreground
axis_handle_out.x_label.background = axis_handle_in.x_label.background
axis_handle_out.x_label.fill_mode = axis_handle_in.x_label.fill_mode
axis_handle_out.x_label.font_style = axis_handle_in.x_label.font_style
axis_handle_out.x_label.font_size = axis_handle_in.x_label.font_size
axis_handle_out.x_label.fractional_font = axis_handle_in.x_label.fractional_font
axis_handle_out.x_label.font_angle = axis_handle_in.x_label.font_angle
axis_handle_out.x_label.auto_position = axis_handle_in.x_label.auto_position
// axis_handle_out.x_label.position = axis_handle_in.x_label.position
axis_handle_out.x_label.auto_rotation = axis_handle_in.x_label.auto_rotation
axis_handle_out.x_label.user_data = axis_handle_in.x_label.user_data
axis_handle_out.x_label.tag = axis_handle_in.x_label.tag
// y_label entities
axis_handle_out.y_label.visible = axis_handle_in.y_label.visible
axis_handle_out.y_label.text = axis_handle_in.y_label.text
axis_handle_out.y_label.font_foreground = axis_handle_in.y_label.font_foreground
axis_handle_out.y_label.foreground = axis_handle_in.y_label.foreground
axis_handle_out.y_label.background = axis_handle_in.y_label.background
axis_handle_out.y_label.fill_mode = axis_handle_in.y_label.fill_mode
axis_handle_out.y_label.font_style = axis_handle_in.y_label.font_style
axis_handle_out.y_label.font_size = axis_handle_in.y_label.font_size
axis_handle_out.y_label.fractional_font = axis_handle_in.y_label.fractional_font
axis_handle_out.y_label.font_angle = axis_handle_in.y_label.font_angle
axis_handle_out.y_label.auto_position = axis_handle_in.y_label.auto_position
//axis_handle_out.y_label.position = axis_handle_in.y_label.position
axis_handle_out.y_label.auto_rotation = axis_handle_in.y_label.auto_rotation
axis_handle_out.y_label.user_data = axis_handle_in.y_label.user_data
axis_handle_out.y_label.tag = axis_handle_in.y_label.tag
// z_label entities
axis_handle_out.z_label.visible = axis_handle_in.z_label.visible
axis_handle_out.z_label.text = axis_handle_in.z_label.text
axis_handle_out.z_label.font_foreground = axis_handle_in.z_label.font_foreground
axis_handle_out.z_label.foreground = axis_handle_in.z_label.foreground
axis_handle_out.z_label.background = axis_handle_in.z_label.background
axis_handle_out.z_label.fill_mode = axis_handle_in.z_label.fill_mode
axis_handle_out.z_label.font_style = axis_handle_in.z_label.font_style
axis_handle_out.z_label.font_size = axis_handle_in.z_label.font_size
axis_handle_out.z_label.fractional_font = axis_handle_in.z_label.fractional_font
axis_handle_out.z_label.font_angle = axis_handle_in.z_label.font_angle
axis_handle_out.z_label.auto_position = axis_handle_in.z_label.auto_position
//axis_handle_out.z_label.position = axis_handle_in.z_label.position
axis_handle_out.z_label.auto_rotation = axis_handle_in.z_label.auto_rotation
axis_handle_out.z_label.user_data = axis_handle_in.z_label.user_data
axis_handle_out.z_label.tag = axis_handle_in.z_label.tag
axis_handle_out.auto_ticks = axis_handle_in.auto_ticks
axis_handle_out.x_ticks = axis_handle_in.x_ticks
axis_handle_out.y_ticks = axis_handle_in.y_ticks
axis_handle_out.z_ticks = axis_handle_in.z_ticks
axis_handle_out.ticks_format = axis_handle_in.ticks_format
axis_handle_out.ticks_st = axis_handle_in.ticks_st
axis_handle_out.box = axis_handle_in.box
axis_handle_out.filled = axis_handle_in.filled
axis_handle_out.sub_ticks = axis_handle_in.sub_ticks
axis_handle_out.font_style = axis_handle_in.font_style
axis_handle_out.font_size = axis_handle_in.font_size
axis_handle_out.font_color = axis_handle_in.font_color
axis_handle_out.fractional_font = axis_handle_in.fractional_font
axis_handle_out.isoview = axis_handle_in.isoview
axis_handle_out.cube_scaling = axis_handle_in.cube_scaling
axis_handle_out.view = axis_handle_in.view
axis_handle_out.rotation_angles = axis_handle_in.rotation_angles
axis_handle_out.log_flags = axis_handle_in.log_flags
axis_handle_out.tight_limits = axis_handle_in.tight_limits
axis_handle_out.data_bounds = axis_handle_in.data_bounds
axis_handle_out.zoom_box = axis_handle_in.zoom_box
axis_handle_out.margins = axis_handle_in.margins
axis_handle_out.auto_margins = axis_handle_in.auto_margins
// do not copy, otherwise axis_handle_out is placed on top of axis_handle_in
//axis_handle_out.axes_bounds = axis_handle_in.axes_bounds
axis_handle_out.auto_clear = axis_handle_in.auto_clear
axis_handle_out.auto_scale = axis_handle_in.auto_scale
axis_handle_out.auto_stretch = axis_handle_in.auto_stretch
axis_handle_out.hidden_axis_color = axis_handle_in.hidden_axis_color
axis_handle_out.hiddencolor = axis_handle_in.hiddencolor
axis_handle_out.line_mode = axis_handle_in.line_mode
axis_handle_out.line_style = axis_handle_in.line_style
axis_handle_out.thickness = axis_handle_in.thickness
axis_handle_out.mark_mode = axis_handle_in.mark_mode
axis_handle_out.mark_style = axis_handle_in.mark_style
axis_handle_out.mark_size_unit = axis_handle_in.mark_size_unit
axis_handle_out.mark_size = axis_handle_in.mark_size
axis_handle_out.mark_foreground = axis_handle_in.mark_foreground
axis_handle_out.mark_background = axis_handle_in.mark_background
axis_handle_out.foreground = axis_handle_in.foreground
axis_handle_out.background = axis_handle_in.background
axis_handle_out.arc_drawing_method = axis_handle_in.arc_drawing_method
axis_handle_out.clip_state = axis_handle_in.clip_state
// do not copy, because of error: sub matrix incorrect defined
// axis_handle_out.clip_box = axis_handle_in.clip_box
axis_handle_out.user_data = axis_handle_in.user_data
axis_handle_out.tag = axis_handle_in.tag
endfunction
t=linspace(0,10*%pi,200);
subplot(1,2,1)
param3d(cos(t),sin(t),t/20)
h=gce();
a1=gca();
a1.isoview=‘on’;
a1.title.text = ‘parametric curve’
a1.title.font_size = 4
a1.x_label.text = ‘myX’;
a1.y_label.text = ‘myY’;
a1.z_label.text = ‘myZ’;
subplot(1,2,2)
a2=gca();
a2 = copyAxisEntities(a1, a2)
copy(h,a2)
Jens
October 28, 2024, 7:24pm
5
Hi philipp
A nice way to copy into subplots!
Another way that leads to the same end is to ignore copy() and write a function instead.
function comax(t,titletex,ax)
param3d(cos(t),sin(t),t/20)
xtitle(titletex)
ax.isoview=‘on’;
ax.title.font_size = 4
ax.x_label.text = ‘myX’;
ax.y_label.text = ‘myY’;
ax.z_label.text = ‘myZ’;
endfunction
close(winsid())
t=linspace(0,10*%pi,200);
subplot(1,2,1)
comax(t,‘First title’,gca())
subplot(1,2,2)
comax(t,‘Second title’,gca())